开发者

Accessing Dictionary keys programmatically

开发者 https://www.devze.com 2023-02-27 03:59 出处:网络
I have an array and a Dictionary and I would like to run some for loops to see if the elements in the array are equal to each of the keys in the Dictionary.

I have an array and a Dictionary and I would like to run some for loops to see if the elements in the array are equal to each of the keys in the Dictionary.

Is there a way to do this using开发者_开发技巧 objective-c?


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

intersection contains a set of the objects that exists both as keys in your dictionary and in your array.

0

精彩评论

暂无评论...
验证码 换一张
取 消