2012-03-30 8 views
0

안녕 아래에 표시하지만,이 코드를 실행할 때 종료하고 콘솔에서 아이폰에해결 방법 - [__ NSCFString JSONValue] : 응용 프로그램이 종료 될 때 인스턴스로 전송되는 인식 할 수없는 선택기?

- (CLLocationCoordinate2D) geoCodeUsingAddress: (NSString *) address 
{ 
    CLLocationCoordinate2D myLocation; 



    NSString *esc_addr = [address stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; 

    NSString *req = [NSString stringWithFormat: @"http://maps.google.com/maps/api/geocode/json?sensor=false&address=%@", esc_addr]; 

    NSDictionary *googleResponse = [[NSString stringWithContentsOfURL: [NSURL URLWithString: req] encoding: NSUTF8StringEncoding error: NULL] JSONValue]; 

    NSDictionary *resultsDict = [googleResponse valueForKey: @"results"]; 
    NSDictionary *geometryDict = [resultsDict valueForKey: @"geometry"];  
    NSDictionary *locationDict = [geometryDict valueForKey: @"location"];  
    NSArray *latArray = [locationDict valueForKey: @"lat"]; 
    NSString *latString = [latArray lastObject]; 
    NSArray *lngArray = [locationDict valueForKey: @"lng"]; 
    NSString *lngString = [lngArray lastObject];  

    myLocation.latitude = [latString doubleValue];  
    myLocation.longitude = [lngString doubleValue]; 

    NSLog(@"lat: %f\tlon:%f", myLocation.latitude, myLocation.longitude); 
    return myLocation; 
} 

오류를 위도와 경도를 얻을 수있는 예외를 처리하는 방법을 아래에 예외를 보여주는 모든 내가 구현 한 코드 :

[1055:11603] -[__NSCFString JSONValue]: unrecognized selector sent to instance 0xabcc200 
[1055:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString JSONValue]: unrecognized selector sent to instance 0xabcc200' 
*** First throw call stack: 
(0x16ee052 0x13d9d0a 0x16efced 0x1654f00 0x1654ce2 0x25a5 0x248f 0x16efec9 0x3945c2 0x39455a 0x439b76 0x43a03f 0x4392fe 0x3b9a30 0x3b9c56 0x3a0384 0x393aa9 0x1de4fa9 0x16c21c5 0x1627022 0x162590a 0x1624db4 0x1624ccb 0x1de3879 0x1de393e 0x391a9b 0x1dcd 0x1d45) 
terminate called throwing an exception(lldb) 
+0

안녕하세요. 프로그램을 자동으로 종료하면 응용 프로그램이 종료되고 – laxmanperamalla

+0

과 같은 메시지가 나타납니다. com.yourcompany.SimpleMapView를 부트 스트랩 서버에 등록 할 수 없습니다. 오류 : 알 수없는 오류 코드. 이것은 일반적으로이 프로세스의 다른 인스턴스가 이미 실행 중이거나 디버거에서 중지 된 상태임을 의미합니다. (lldb) – laxmanperamalla

답변

2

당신은 아마 당신의 JSON 라이브러리를 포함 깜빡하고 NSString JSONValue 카테고리가 없습니다. 당신은 기본적으로있는 NSString 인스턴스에 JSONValue 메시지를 보내는

-1

, 즉 응용 프로그램이 여기에, 충돌되는 이유는 다음과 같습니다

NSDictionary *googleResponse = [[NSString stringWithContentsOfURL: [NSURL URLWithString: req] encoding: NSUTF8StringEncoding error: NULL] JSONValue]; 
0

개발 버전에서 버그가 수 있도록 나타납니다. from here

관련 문제