// Method 1 - Simplest method to solve above problem (Use NSArray's containsObject method)
NSArray *array1 = [[NSArray alloc] initWithObjects:@"a",@"b",@"c",@"e", nil];
NSArray *array2 = [[NSArray alloc] initWithObjects:@"a",@"d",@"c",@"f", nil];
for(id i in array1){
if ([array2 containsObject:i]) {
// do something
}
else {
// do something else
}
}
// Method 2 - Another method (Use NSString's isEqualToString method)
NSArray *array1 = [[NSArray alloc] initWithObjects:@"a",@"b",@"c",@"e", nil];
NSArray *array2 = [[NSArray alloc] initWithObjects:@"a",@"d",@"c",@"f", nil];
for(id i in array1){
for(id j in array2){
if ([i isEqualToString:j]) {
// do something
}
else {
//do something else
}
}
}