Re: compare two array
Re: compare two array
- Subject: Re: compare two array
- From: Andy Lee <email@hidden>
- Date: Sat, 1 Apr 2006 23:42:03 -0500
On Apr 1, 2006, at 11:03 PM, Jerry Krinock wrote:
on 06/04/01 16:50, Yorh at email@hidden wrote:
I have two Arrays onr with a varibla number of objects and the second
one too.
I have to remove from the first array the object that isn't present
in the second one, but I can't find if there is some method to do
it...
I don't believe there is. Write your own method and put it in a
category to
NSMutableArray. Enumerate through the second array using -
indexOfObject.
You could also do
NSMutableArray *objectsToRemove = [NSMutableArray
arrayWithArray:firstArray];
[objectsToRemove removeObjectsInArray:secondArray];
[firstArray removeObjectsInArray:tempArray];
This may not be as efficient as writing your own, but unless you're
dealing with huge numbers of objects it may not matter.
If you go with NSSets as has been suggested by others, it's even
simpler and more efficient -- there's a method called intersectSet:.
--Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden