0

我正在使用谷歌反向地理编码来获取用户的当前位置。我的代码是这样的:

    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]];

现在我如何从这里继续获取用户的当前位置?

4

1 回答 1

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
}];
于 2013-07-21T16:31:01.617 回答