2011-11-15 9 views
0

現在の場所を取得し、文字列にlatとlongを入れるコードを用意しました。iOS - 文字列エラー

NSLog(currentLatit); 

[[UIApplication sharedApplication] openURL:[[NSURL alloc] initWithString: [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%@,%@&daddr=%@,%@",currentLatit,currentLongit,detailLatitudine,detailLongitudine]]]; 

が、私はこれを実行すると、私はこのエラーを取得:

新しい場所が見つかったときに私は私がやるのボタンを押したときよりもNSStringの

currentLatit = [NSString stringWithFormat:@"%f",newLocation.coordinate.latitude]; 
currentLongit = [NSString stringWithFormat:@"%f",newLocation.coordinate.longitude]; 

にそれを置きます:

-[__NSCFArray length]: unrecognized selector sent to instance 0x1e1830 
2011-11-15 11:29:07.567 Marcovaldo[771:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray length]: unrecognized selector sent to instance 0x1e1830' 
*** First throw call stack: 
(0x30ae78bf 0x37c8c1e5 0x30aeaacb 0x30ae9945 0x30a44680 0x30a310a9 0x30ac5a97 0x30a42217 0x30a55b8f 0x37b09b9b 0x37b09b3b 0x7253 0x30a41435 0x32a9c9eb 0x32a9c9a7 0x32a9c985 0x32a9c6f5 0x32a9c321 0x32a8f99b 0x30abbb4b 0x30ab9d87 0x30aba0e1 0x30a3d4dd 0x30a3d3a5 0x3366bfed 0x32aaf743 0x2221 0x21e0) 
terminate called throwing an exception(gdb) 

エラーのNSLog実行

で発生

は本当に間違って聖霊降臨祭は、この単純なコードだか理解できません...任意の助け

-UPDATE-

ため

感謝は以下の通りのNSLogを変更:今すぐ

NSLog(@"%@",currentLatit); 

アプリNSLogのBAD_ACCESS_EXCEPTIONでクラッシュする

+0

「NSLog(@ "%@"、currentLatit);」を意味しましたか? –

+0

ヒントをありがとう、私はあなたの提案でコードを更新しました、今私は同じポイントでBAD_ACCESS_EXEPTIONを与えます –

+0

Gomathiが示唆したように、あなたの環境変数にNSZombieEnabledを追加してみてください。また、NSLogのnewLocationを試して、万が一nullでないことを確認してください。 –

答えて

2

いいえ、NSLog以外の場所でアプリがクラッシュしたようです。きれいにしてビルドしてください。またはNSZombieを有効にし、正確なエラー位置を取得します。

更新:

次のようにして試してみてください。

if(currentLatit) 
    [currentLatit release]; 
if(currentLongit) 
    [currentLongit release]; 
currentLatit = [[NSString stringWithFormat:@"%f",newLocation.coordinate.latitude] retain]; 
currentLongit = [[NSString stringWithFormat:@"%f",newLocation.coordinate.longitude] retain]; 
+0

あなたは私のヒーローです!それは動作します! –