• 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: NSComparisonPredicate vs. predicateWithFormat
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSComparisonPredicate vs. predicateWithFormat


  • Subject: Re: NSComparisonPredicate vs. predicateWithFormat
  • From: Daniel DeCovnick <email@hidden>
  • Date: Sat, 24 Nov 2012 01:59:16 -0800

The rightExpression should be [NSExpression expressionForConstantValue:deletedAlertIDs]. The collection passed to expressionForAggregate: should itself contain expressions, according to the docs. I'm not exactly sure what that's for, but expressionForConstantValue: is definitely what you want here.

Daniel


On Nov 23, 2012, at 9:52 PM, Rick Mann wrote:

> I'm trying to set up an "IN" predicate like this:
>
>    NSArray* deletedAlertIDs = @[ @198, @197 ];
>    NSPredicate* pred =
>        [NSComparisonPredicate predicateWithLeftExpression: [NSExpression expressionForKeyPath: @"keyShadow"]
>            rightExpression: [NSExpression expressionForAggregate: deletedAlertIDs]
>            modifier: NSDirectPredicateModifier
>            type: NSInPredicateOperatorType
>            options: 0];
>    req.predicate = pred;
>
> But it doesn't work, even though NSLog() shows it as "keyShadow IN {198, 197}", which is the same as what I get when I use this code that works:
>
>
>    req.predicate = [NSPredicate predicateWithFormat: @"keyShadow IN %@", deletedAlertIDs];
>
> Clearly something is different between the two that's not shown in the description.
>
> --
> Rick
>
>
>
>
> _______________________________________________
>
> 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

_______________________________________________

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: NSComparisonPredicate vs. predicateWithFormat
      • From: Rick Mann <email@hidden>
References: 
 >NSComparisonPredicate vs. predicateWithFormat (From: Rick Mann <email@hidden>)

  • Prev by Date: overriding a method with NSObject's version
  • Next by Date: Re: NSComparisonPredicate vs. predicateWithFormat
  • Previous by thread: NSComparisonPredicate vs. predicateWithFormat
  • Next by thread: Re: NSComparisonPredicate vs. predicateWithFormat
  • Index(es):
    • Date
    • Thread