• 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: Pierce Freeman <email@hidden>
  • Date: Sat, 29 Nov 2008 10:00:04 -0800
  • Thread-topic: Checking One Array Against Another

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);


Sincerely,

Pierce F.





On 11/28/08 10:51 PM, "Graff" <email@hidden> wrote:

> On Nov 28, 2008, at 9:59 PM, Pierce Freeman wrote:
>
>> Would there be some way using the NSSet method to output a list of the
>> applications that the user needs to close in order for the current
>> applications to be "in the good list"?
>
> You can use the NSMutableSet method minusSet:
>
> NSSet *allowedSet = [NSSet setWithObjects:@"one",@"two",@"three",nil];
> NSMutableSet *openSet = [NSMutableSet
> setWithObjects:@"one",@"four",@"five",nil];
>
> if([openSet isSubsetOfSet:allowedSet])
> NSLog(@"The user has only the okay applications open");
> else
> {
> NSLog(@"The user has these not okay applications open:");
> [openSet minusSet:allowedSet];
> for(id anItem in openSet)
> NSLog(anItem);
> }
>


_______________________________________________

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

  • Follow-Ups:
    • Re: Checking One Array Against Another
      • From: Graff <email@hidden>
    • Re: Checking One Array Against Another
      • From: Graff <email@hidden>
    • Re: Checking One Array Against Another
      • From: Klaus Backert <email@hidden>
References: 
 >Re: Checking One Array Against Another (From: Graff <email@hidden>)

  • Prev by Date: Re: Keystrokes for non-ascii letters
  • Next by Date: Re: Keystrokes for non-ascii letters
  • Previous by thread: Re: Checking One Array Against Another
  • Next by thread: Re: Checking One Array Against Another
  • Index(es):
    • Date
    • Thread