Objective-C - How to compare arrays and extract the difference?

Viewed 25999

Possible duplicate: comparing-two-arrays

I have two NSArray and I'd like to create a new Array with objects from the second array but not included in the first array.

Example:

NSMutableArray *firstArray = [NSMutableArray arrayWithObjects:@"Bill", @"Ben", @"Chris", @"Melissa", nil];
NSMutableArray *secondArray = [NSMutableArray arrayWithObjects:@"Bill", @"Paul", nil];

The resulting array should be: 

[@"Paul", nil];

I solved this problem with a double loop comparing objects into the inner one.

Is there a better solutions ?

3 Answers
Related