如何解决上述错误?
我使用以下代码使用 google maps api 从地址字符串中获取 latlong
- (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;
}
在里面
NSDictionary *googleResponse = [[NSString stringWithContentsOfURL: [NSURL URLWithString: req] encoding: NSUTF8StringEncoding error: NULL] JSONValue];
行,我收到错误Automatic Reference Counting Issue: No known instance method for selector 'JSONValue'
我的项目使用 ARC。
如何解决该错误?