For getting indexes of objects in array1
which are also present in array2
, you can use:
NSIndexSet* indexes = [array1 indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
return [array2 containsObject:obj];
}];
[indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
NSLog(@"Index is %u", idx); //do whatever you need to do with the index
}];