NSPredicate help (String value in NSArray?)
NSPredicate help (String value in NSArray?)
- Subject: NSPredicate help (String value in NSArray?)
- From: Claus Atzenbeck <email@hidden>
- Date: Mon, 26 Nov 2007 10:09:58 +0100 (CET)
Hi all:
I need some help with NSPredicate. Two objects are relevant in that
context:
(1) NSArray authors (that is an Array of NSString objects)
(2) NSString [self wikiID] (returns an NSString object)
I want to see if the string value returned by [self wikiID] is in
NSArray authors:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NSPredicate *containsPredicate = [NSPredicate predicateWithFormat:@"SELF IN %@", authors];
if ([containsPredicate evaluateWithObject:[self wikiID]]) {
NSLog(@"YES");
} else {
NSLog(@"NO");
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
No success, even if the string value can be found in the array.
(Possibly because it does not compare the string values but their IDs
instead.)
How do I correctly use NSPredicate to check if a given string values is
in a given array?
Thanks for your hints.
Cheers,
/CA
_______________________________________________
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