2011-11-15 1 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 실행 발생

,691

NSLog(@"%@",currentLatit); 

을 이제 응용 프로그램 : 정말 잘못된 오순절이 간단한 코드 무엇을 이해할 수 없다

... 어떤 도움

-UPDATE-

에 대한

덕분에 다음과 같은 NSLog 변경 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

당신은 내 영웅입니다! 그것은 작동합니다! –