I have one NSArray
with names in string objects like this:@[@\"john\", @\"smith\", @\"alex\",
@\"louis\"]
, and I have another array that contains
You can use the concept of [NSArray containsObject:]
, where your objects will be from your array1 like you say "john","smith","alex","loui"
Run a loop and use isEqualToStiring
to verify whether array1 objects exists in mainArray.
If you just need to check if all objects from array1 are in mainArray, you should just use NSSet
e.g.
BOOL isSubset = [[NSSet setWithArray:array1] isSubsetOfSet:[NSSet setWithArray:mainArray]]
if you need to check which objects are in mainArray, you should take a look at NSMutableSet
NSMutableSet *array1Set = [NSMutableSet setWithArray:array1];
[array1Set intersectSet:[NSSet setWithArray:mainArray]];
//Now array1Set contains only objects which are present in mainArray too