How to cross two arrays in lens C?

I have two arrays. Array1 contains 15 objects, and Array2 contains 4 objects. There are two common objects from both arrays, I just want to get the resulting array from these two objects.

It should be like the intersection of two Set, but how to do in Objective-C for an array ..? Please help. Thank you

+16
objective-c iphone nsmutablearray intersection nsmutableset
Aug 29 '12 at 8:39
source share
1 answer

Using NSMutableSet

NSMutableSet *set1 = [NSMutableSet setWithArray: array1]; NSSet *set2 = [NSSet setWithArray: array2]; [set1 intersectSet: set2]; NSArray *resultArray = [set1 allObjects]; 
+46
Aug 29 '12 at 8:50
source share



All Articles