我正在使用Google反向地理编码来获取用户的当前位置。我的代码是这样的:
NSString* StrCurrentLongitude=[NSString stringWithFormat: @"%f", currentLocation.coordinate.longitude]; // string value
NSString* StrCurrentLatitude=[NSString stringWithFormat: @"%f", currentLocation.coordinate.latitude];
[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=%@,%@&sensor=true_or_false",StrCurrentLatitude,StrCurrentLongitude]];
现在我如何从这里继续获取用户的当前位置?
答案 0 :(得分:1)
:
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithUrl:yourURL] queue:[NSOperationQueue mainQueue] completion:^(NSURLResponse *r, NSData *d, NSError *e) {
//decode it
id json = [NSJSONSerialization JSONObjectWithData:d options:0 error:nil];
//process google response, which is JSON IIRC
}];