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:10:23 -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);
The method minusSet: is an NSMutableSet method but you are
constructing an NSSet and assigning it to a NSMutableSet pointer:
NSMutableSet *openApplicationsSet = [NSSet
setWithArray:openApplications];
That's why you get the error "mutating method sent to immutable
object". You should instead do the following:
NSMutableSet *openApplicationsSet = [NSMutableSet
setWithArray:openApplications];
Since NSMutableSet inherits from NSSet you can still use the
setWithArray: method to create the set.
_______________________________________________
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