• 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
NSPredicate help (String value in NSArray?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSPredicate help (String value in NSArray?)
      • From: Jaime Magiera <email@hidden>
  • Prev by Date: Re: Core Data and RDBs
  • Next by Date: Re: Finding the height of a piece of text
  • Previous by thread: Re: Core Data and RDBs
  • Next by thread: Re: NSPredicate help (String value in NSArray?)
  • Index(es):
    • Date
    • Thread