2011-04-20 133 views
1

我有一个数组和字典,我想运行一些for循环来查看数组中的元素是否与字典中的每个键相等。以编程方式访问字典键

有没有办法使用objective-c来做到这一点?

+0

你能提供你的数组和字典的样本吗? – 2011-04-20 18:23:43

+0

可以将数组中的对象与字典中的对象进行比较,是的。你试过什么了? – 2011-04-20 18:31:26

回答

1
NSMutableSet *intersection = [[NSMutableSet alloc] init]; 
[intersection addObjectsFromArray:array]; 
[intersection intersectSet:[NSSet setWithArray:[dictionary allKeys]]]; 

intersection包含一组都存在在你的字典键和您的阵列中的对象。