2013-02-28 122 views

回答

1
- (void) getAddress 
{ 
    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://maps.google.com/maps/api/geocode/json?latlng=31.319016,-86.399871&sensor=false"]]; 
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil]; 
    NSString *str = [[[dict objectForKey:@"results"] objectAtIndex:0] valueForKey:@"formatted_address"]; 
    NSLog(@"Address = %@", str); 

} 

使用格式的地址一樣溫頓,AL,美國谷歌Web服務的在我的iPhone

這json這是比xml快得多。

+0

但我想在xml代碼 – Gaurav 2013-02-28 13:48:00

+0

我想這一個卡溫頓,AL,美國bcoz每次索引更改時,位置變化 – Gaurav 2013-02-28 13:51:16

+0

你是對的。 JSON這個比xml快得多。 – Gaurav 2013-09-16 11:57:12