Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone NSArray用于中断信息的帮助_Iphone_Json_Nsarray - Fatal编程技术网

Iphone NSArray用于中断信息的帮助

Iphone NSArray用于中断信息的帮助,iphone,json,nsarray,Iphone,Json,Nsarray,嗨 我从服务器“{\”bindings\”:[{\“Latitude\”:“25.451808633333332\,“Longitude\”:“81.83372523333333\”}]得到一个响应,它在数组中,我需要将纬度和经度部分或值打断,并将值初始化为另一个字符串 NSString *latitudeString = [[[jsonDict objectForKey:@"bindings"]objectAtIndex:0]objectForKey:@"Latitude"]; NSStrin

嗨 我从服务器“{\”bindings\”:[{\“Latitude\”:“25.451808633333332\,“Longitude\”:“81.83372523333333\”}]得到一个响应,它在数组中,我需要将纬度和经度部分或值打断,并将值初始化为另一个字符串

NSString *latitudeString = [[[jsonDict objectForKey:@"bindings"]objectAtIndex:0]objectForKey:@"Latitude"];
NSString *longitudeString = [[[jsonDict objectForKey:@"bindings"]objectAtIndex:0]objectForKey:@"Longitude"];
以更美好的方式:

NSDictionary *gealocationDict = [[jsonDict objectForKey:@"bindings"]objectAtIndex:0];
NSString *latitudeString  = [gealocationDict objectForKey:@"Latitude"];
NSString *longitudeString = [gealocationDict bjectForKey:@"Longitude"];

这看起来更像JSON,而不是NSArrayyes。它在JSON中,但是值不在字典中,而是在数组中。感谢您提供的信息,但是我之前提到过,来自服务器的信息是在数组中而不是在字典中。如果您提供的字符串是来自服务器的响应,则为和字典。粘贴响应字符串,我将编辑我的帖子。字典以“{”开头,数组以“[”开头。