Re: Checking One Array Against Another
Re: Checking One Array Against Another
- Subject: Re: Checking One Array Against Another
- From: Graff <email@hidden>
- Date: Sat, 29 Nov 2008 14:26:38 -0500
On Nov 29, 2008, at 1:00 PM, Pierce Freeman wrote:
The only problem with running that is that I get a error in the log
and it
doesn't seem to be working:
-[NSCFSet minusSet:]: mutating method sent to immutable object
My slightly modified code is below:
NSMutableSet *openApplicationsSet = [NSSet
setWithArray:openApplications];
NSSet *allowedApplicationsSet = [NSSet
setWithArray:applicationsAllowedMutableArray];
NSSet *badApplicationsSet = [openApplicationsSet
minusSet:allowedApplicationsSet];
NSLog(badApplicationsSet);
Also, because minusSet: actually modifies the set it is being called
on there is no need to create a new pointer to hold the resulting
set. You can just do something like the following:
NSSet *allowedApplicationsSet = [NSSet
setWithArray:applicationsAllowedMutableArray];
NSMutableSet *badApplicationsSet = [NSMutableSet
setWithArray:openApplications];
[badApplicationsSet minusSet:allowedApplicationsSet];
NSLog([NSString stringWithFormat:@"badApplicationsSet: %@",
badApplicationsSet]);
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden