この一連の JSON データ全体の緯度と経度の値を取得したいと思います。
{
branches = (
{
city = "Las Vegas";
country = "United States";
countryIsoCode = USA;
distanceInKms = "3.35";
distanceInMiles = "2.08";
id = 15739653;
latitude = "36.029102";
longitude = "-115.114960";
name = "Las Vegas - 89123";
state = Nevada;
stateIsoCode = NV;
street = "8876 Eastern Avenue";
telephone = "";
}
);
id = 355896;
logoUrl = "http://d2bvnbhf12ry1m.cloudfront.net";
name = "Body Heat";
},
{
branches = (
{
city = "Las Vegas";
country = "United States";
countryIsoCode = USA;
distanceInKms = "18.09";
distanceInMiles = "11.24";
id = 6043133;
latitude = "36.143978";
longitude = "-115.280380";
name = "Las Vegas - 8645 W Sahara Ave.";
state = Nevada;
stateIsoCode = NV;
street = "8645 W Sahara Ave.";
telephone = "";
}
);
id = 121022;
logoUrl = "http://d2bvnbhf12ry1m.cloudfront.net/31513.jpg";
name = "Just Face It Medspa";
},
{
branches = (
{
city = Henderson;
country = "United States";
countryIsoCode = USA;
distanceInKms = "3.66";
distanceInMiles = "2.27";
id = 4563174;
latitude = "35.997353";
longitude = "-115.120628";
name = Henderson;
state = Nevada;
stateIsoCode = NV;
street = "3035 W Horizon Ridge Pkwy., Suite 100";
telephone = "";
}
);
id = 57146;
logoUrl = "http://d2bvnbhf12ry1m.cloudfront.net/31513.jpg";
name = "Signature Institute of Aesthetic Sculpting";
},
{
branches = (
{
city = "Las Vegas";
country = "United States";
countryIsoCode = USA;
distanceInKms = "9.71";
distanceInMiles = "6.03";
id = 13769564;
latitude = "36.106091";
longitude = "-115.166840";
name = "Las Vegas - 89109";
state = Nevada;
stateIsoCode = NV;
street = "145 East Harmon Avenue";
telephone = "";
}
);
id = 272131;
logoUrl = "http://d2bvnbhf12ry1m.cloudfront.net";
name = "Luxury Suites International";
},
{
branches = (
{
city = "Las Vegas";
country = "United States";
countryIsoCode = USA;
distanceInKms = "25.24";
distanceInMiles = "15.68";
id = 10385118;
latitude = "36.238758";
longitude = "-115.224167";
name = Northwest;
state = Nevada;
stateIsoCode = NV;
street = "5803 W Craig Rd., Suite 104";
telephone = "";
},
{
city = "Las Vegas";
country = "United States";
countryIsoCode = USA;
distanceInKms = "5.65";
distanceInMiles = "3.51";
id = 9391473;
latitude = "36.067402";
longitude = "-115.172226";
name = "Posare Salon Town Square";
state = Nevada;
stateIsoCode = NV;
street = "6569 S Las Vegas Blvd.";
telephone = "";
}
);
id = 216657;
logoUrl = "http://d2bvnbhf12ry1m.cloudfront.net";
name = "Posare Salons";
}
);
owners = (
{
id = 1;
logoUrl = "http://d2bvnbhf12ry1m.cloudfront.net/media/1830.gif";
name = OneBigPlanet;
type = group;
}
);
どうすればいいですか?以下を使用して試してみましたが、エラーが返され続けます
GoogleAnalytics 2.0b4 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:41): キャッチされない例外: -[__NSCFString objectForKeyedSubscript:]: 認識されないセレクターがインスタンス 0xa9f9e90 2013-09-09 14:24:46.851 に送信されました * 例外がキャッチされないため、アプリを終了します'NSInvalidArgumentException', reason: '-[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0xa9f9e90' * First throw call stack: (0x2f7d012 0x2780e7e 0x30084bd 0x2f6cbbc 0x2f6c94e 0x118646 0x125952 0x126e59 0x2a0053f 0x2a12014 0x2a027d5 0x2f23af5 0x2f22f44 0x2f22e1b 0x2ed77e3 0x2ed7668 0x16c4ffc 0x51d1d 0x3285) libc+ +abi.dylib: 例外をスローして呼び出しを終了 (lldb)
すべての経度と緯度を取得して doubleValue として保存し、ポイントをマップにプロットしようとしています。何か案は?
NSURL *url = [[NSURL alloc] initWithString:@"http://api.onebigplanet.com/ws/local-daily-deals?wsToken=&wsVersion=3.0.0&categoryId=1&categoryId=2&numItems=0&out=json&sort=distance&zipCode=89123&radiusInMiles=100&latitude&longitude"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"%@",JSON);
self.mapLocations = JSON;
for(NSDictionary *locations in self.mapLocations) {
//NSLog(@"%@",locations[@"merchants"][0][@"branches"][0][@"latitude"]);
NSLog(@"Latitude: %@", locations);
}
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response,
NSError *error, id JSON) {
NSLog(@"NSError: %@",error.localizedDescription);
}];
[operation start];