我的回应是
{"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
{
if ([RecievedDataBus length]>0)
{
NSString*mystring=[[NSString alloc]initWithData:RecievedDataBus encoding:NSUTF8StringEncoding];
NSLog(@"%@",mystring);
NSError *error;
NSDictionary *result=[NSJSONSerialization JSONObjectWithData:RecievedDataBus options:NSJSONWritingPrettyPrinted error:&error];
NSDictionary*Dictionary=[result objectForKey:@"vehicle_id"];
FinalbusIDs = [[NSMutableArray alloc] initWithArray:[Dictionary valueForKey:@"ID"]];
for (int i=0;i<[FinalbusIDs count]; i++)
{.....}}
然后再次对于另一个请求,控件再次进入此 didfinishloading .....对于第二个请求。第一次它正常工作。但是第二次 CFString 既有以前的 CFString 又有新的。