Re: NSPredicate and NOT IN and array
Re: NSPredicate and NOT IN and array
- Subject: Re: NSPredicate and NOT IN and array
- From: Greg Herlihy <email@hidden>
- Date: Tue, 23 May 2006 19:13:13 -0700
- Thread-topic: NSPredicate and NOT IN and array
Just wrap the affirmative predicate in parentheses and place a NOT in front
of it:
[NSPredicate predicateWithFormat:@"NOT (id in %@)", listOfIDs];
Greg
On 5/23/06 3:00 PM, "David Alter" <email@hidden> wrote:
> I would like to get an array of items that are NOT IN and array. Is
> there a way to do this with a NSPredicate
>
> Example:
>
> NSArray *listOfIDs = [self getSomeIDs];
> NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init]
> autorelease];
> [fetchRequest setEntity:
> [NSEntityDescription entityForName:@"items"
> inManagedObjectContext:myMOC ] ];
> [fetchRequest setPredicate: [NSPredicate predicateWithFormat: @"(id
> NOT IN %@)", listOfIDs]];
>
> Any ideas would be great.
>
> thanks
> -dave
>
>
> _______________________________________________
> 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
_______________________________________________
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