我正在开发一个推特应用程序并尝试实现推文位置。我想要的只是显示国家名称,如果推文有位置,则将其显示在地图上。但是无论我尝试过什么,它总是显示第一条推文的国家,或者如果它为空,应用程序就会崩溃。我不明白我做错了什么。任何人都可以帮忙吗?谢谢!这是我的代码:
// LOCATION
for (NSDictionary *dic in self.dataSource)
{
NSString *str = [dic valueForKeyPath:@"place.name"];
if(str)
{
cell.button.hidden = NO;
cell.location.text = [dic valueForKeyPath:@"place.full_name"];
self.coordinates = [dic valueForKeyPath:@"geo.coordinates"];
break;
} else {
cell.button.hidden = YES;
cell.location.hidden = YES;
break;
}
}
这是 NSLog 输出:
2013-08-20 00:04:42.269 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.269 TwitterApplication[10011:c07] Downtown
2013-08-20 00:04:42.269 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.270 TwitterApplication[10011:c07] Moscow
2013-08-20 00:04:42.270 TwitterApplication[10011:c07] Брянск
2013-08-20 00:04:42.270 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.271 TwitterApplication[10011:c07] Брянск
2013-08-20 00:04:42.271 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.271 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.272 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.272 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.272 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.273 TwitterApplication[10011:c07] <null>
2013-08-20 00:04:42.273 TwitterApplication[10011:c07] <null>