• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Checking One Array Against Another
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Checking One Array Against Another (From: Pierce Freeman <email@hidden>)

  • Prev by Date: RE: UIViewController memory warnings | didReceiveMemoryWarning |
  • Next by Date: Re: reading a PDF
  • Previous by thread: Re: Checking One Array Against Another
  • Next by thread: Still unable to work out mouse position
  • Index(es):
    • Date
    • Thread