I have 2 array of strings, lets say for simplicity it will be Array 1 - @[@"a",@"b",@"c"]
and Array 2 will be - @[@"b",@"c", @"d"]
.
What i want is, to create an array from strings (yes, there will be strings, sometimes long enough, i put characters just for simplicity) that exclude strings contained in previous array. And second array, that otherwise, contain string that exist in first array and not exist in second.
So, with array i privded, it would be :
resultArray1 = @[@"d]
(exist in second array, but not in first)
resultArray2 = @[@"a"]
(exist in first array, but not in second)
How to enumerate through this arrays to get what i want to? Thanks.
Make a NSMutableArray
from the array with the items you want to keep, and call removeObjectsInArray:
on it:
NSMutableArray res1 = [arr1 mutableCopy];
[res1 removeObjectsInArray:arr2];
NSMutableArray res2 = [arr2 mutableCopy];
[res2 removeObjectsInArray:arr1];