我有一个这样的数组:
(
{
City = SanFransisco;
Latitude = "28.602704";
},
{
City = SanFransisco;
Latitude = "28.49379";
},
)
如何检查数组是否包含名为City at 0 index的键?
答案 0 :(得分:5)
NSEnumerator *e = [array objectEnumerator];
id object;
while (object = [e nextObject]) {
if([object objectForKey:@"City"] !=nil)
return TRUE;
}
如果没有迭代:
id object = [array objectAtIndex:0];
if([object objectForKey:@"City"] !=nil)
return TRUE;