I have multiple arrays, for example:
NSArray *a = @[@"a", @"b", @"c"];
NSArray *b = @[@"d", @"a", @"e"];
NSArray *c = @[@"i", @"f", @"a"];
As you can see "a" is exist in array a, b, c. I would like to make a function that return the same objet in supplied arrays. So, like this one, I want to get this "a" from them. if all arrays don't have the same object, which will return nil. For example "f" only exist in c, so the function should return nil.
NSMutableSet *set = [NSMutableSet new];
NSMutableSet *set1 = [NSMutableSet setWithArray:a];
NSMutableSet *set2 = [NSMutableSet setWithArray:b];
NSMutableSet *set3 = [NSMutableSet setWithArray:c];
set = [set1 intersectSet:set2];
set = [set intersectSet:set3];
NSArray *allArray = [set allObjects];