返された一連のツイートをループして、テキスト コンポーネントと座標を取得しています。以下のようにコードを設定しました。これはテキストを取得しますが、座標は取得しません。何が間違っているのかわかりません。返されたパスを確認しましたが、返された文字列の一部に次が含まれています
"geo":{"coordinates":[51.479361,-0.215066],"type":"Point"},
したがって、間違いなく座標が返されます。これが私のコードです...
for (NSDictionary *tweet in results) {
// Get the tweet
NSString *twittext = [tweet objectForKey:@"text"];
// Save the tweet to the twitterText array
[_twitterText addObject:twittext];
id jsonResult = [tweet valueForKeyPath:@"geo.coordinates"];
if ([NSNull null] != jsonResult) {
if (2 == [jsonResult count]) {
NSDecimalNumber* longitude = [jsonResult objectAtIndex:0];
NSDecimalNumber* latitude = [jsonResult objectAtIndex:1];
if (longitude && latitude) {
// here you have your coordinates do whatever you like
[twitterLocation addObject:[NSString stringWithFormat:@"%@,%@", latitude, longitude]];
}
else {
NSLog(@"Warning: bad coordinates: %@", jsonResult);
}
}
else {
NSLog(@"Warning: bad coordinates: %@", jsonResult);
}
}*/
}