Iphone 如何从响应字典中提取纬度和经度?
我的回答是Iphone 如何从响应字典中提取纬度和经度?,iphone,ios,Iphone,Ios,我的回答是 {"Vehicle":[ {"ID":"11","latitude":"8.513333","longitude":"76.969722"}, {"ID":"12","latitude":"8.565","longitude":"76.879722"}, {"ID":"15","latitude":"8.565","longitude":"76.879444"}, {"ID":"16","latitude":"8.543333","longitude":"76
{"Vehicle":[
{"ID":"11","latitude":"8.513333","longitude":"76.969722"},
{"ID":"12","latitude":"8.565","longitude":"76.879722"},
{"ID":"15","latitude":"8.565","longitude":"76.879444"},
{"ID":"16","latitude":"8.543333","longitude":"76.913333"}
]}
如何分别提取每个id的纬度和经度?
我想找到最近的坐标
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
然后,对于另一个请求,控件再次执行此didfinishloading…。对于第二个请求,它第一次工作正常。但是对于第二个tim,CFString同时具有以前的CFString和新的CFString。首先将数据存储在字典dic中,然后执行此操作
double latitue = [[[dic valueForKeyPath:@"Vehicle.latitude"] objectAtIndex:0] doubleValue]];
double longitude = [[[dic valueForKeyPath:@"Vehicle.longitude"] objectAtIndex:0] doubleValue]];
NSLog(@"Latitude %g",latitue);
NSLog(@"Longitude %g",longitude);
//对更多索引执行相同操作实际上,我在同一类中收到了一个响应字典,而这一个是另一个请求的第二个响应。因此,CFString将两个数据放在一起,并且在JSON序列化后在字典中提取其显示对象。这是我的代码……我应该如何获得纬度a下一个请求响应的经度。@JubingVarughese您需要学习。
double latitue = [[[dic valueForKeyPath:@"Vehicle.latitude"] objectAtIndex:0] doubleValue]];
double longitude = [[[dic valueForKeyPath:@"Vehicle.longitude"] objectAtIndex:0] doubleValue]];
NSLog(@"Latitude %g",latitue);
NSLog(@"Longitude %g",longitude);