NSString *urlPath=[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=%f,%f&destination=%f,%f&sensor=false",coordinate1.latitude,coordinate1.longitude,coordinate2.latitude,coordinate2.longitude];
//NSLog(@"the url for searching is : %@",urlPath);
NSURL *url=[NSURL URLWithString:urlPath];
NSData *data=[NSData dataWithContentsOfURL:url];
NSDictionary *object = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSNumber *results = [[[[object valueForKey:@"routes"]valueForKey:@"legs"]valueForKey:@"distance"]valueForKey:@"value"];
NSLog(@"Count %@",results);
結果出來的值:獲取無支架
(
(
12078
)
)
是有可能只得到多少呢?
你能在一個代碼塊再次發佈您的代碼,所以我們可以看了嗎? –
你沒有得到一個數字,你得到一個數組數組。 – zneak
[JSONKit](https://github.com/johnezang/JSONKit)可能會爲您節省一些時間。 – johnMa