위의 오류를 해결하는 방법? 'JSONValue'선택기에 대한 알려진 인스턴스 메서드가 없습니다
가 나는 오류를 가지고 자동 참조 계산 문제는NSDictionary *googleResponse = [[NSString stringWithContentsOfURL: [NSURL URLWithString: req] encoding: NSUTF8StringEncoding error: NULL] JSONValue];
라인에서 구글지도 API를
- (CLLocationCoordinate2D) geoCodeUsingAddress:(NSString *)address
{
double latitude = 0.0;
double longitude = 0.0;
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"]; // get the results dictionary
NSDictionary *geometryDict = [resultsDict valueForKey: @"geometry"]; // geometry dictionary within the results dictionary
NSDictionary *locationDict = [geometryDict valueForKey: @"location"]; // location dictionary within the geometry dictionary
NSArray *latArray = [locationDict valueForKey: @"lat"];
NSString *latString = [latArray lastObject]; // (one element) array entries provided by the json parser
NSArray *lngArray = [locationDict valueForKey: @"lng"];
NSString *lngString = [lngArray lastObject]; // (one element) array entries provided by the json parser
CLLocationCoordinate2D location;
location.latitude = [latString doubleValue];// latitude;
location.longitude = [lngString doubleValue]; //longitude;
return location;
}
를 사용하여 주소 문자열에서 latlong를 얻기 위해 아래의 코드를 사용하지 : 알려진 바 없음을 선택기 'JSONValue'에 대한 인스턴스 메서드
내 프로젝트는 ARC를 사용합니다.
어떻게 해결할 수 있습니까?
"XXXJSON.h"를 꺼 냈습니까? –
http://stackoverflow.com/questions/9762432/get-values-from-json-string-objective-c – Bigood