I have 2 arrays, one of which is NSMutableArray (say mutArrayA) and other is NSArray(arrayB).
I am appending arrayB to mutArrayA and at the same time I want to remove duplicates if any i.e. I don't want any duplicates in mutArrayA.
One way I know to do this is iterating over each object in the arrayB and checking its index using indexOfObject which if found in mutArrayA, then don't append that object to mutArrayA else append it. However I was trying to look for some quicker way to do this and I came across the following solution on this site which goes as below:
[mutArrayA setArray:[[NSSet setWithArray:arrayB] allObjects]];
When I execute this, my mutArrayA gets replaced with objects in arrayB because of setArray. Is there a quicker way using which I can append the array without getting the duplicates.