• 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: NSPredicate and nil variables.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPredicate and nil variables.


  • Subject: Re: NSPredicate and nil variables.
  • From: Todd Blanchard <email@hidden>
  • Date: Wed, 6 Jul 2005 21:28:39 -0700

Instead of trying to put nil into NSDictionary, you can use the placeholder [NSNull null] if you are explicitly searching for an object with a property that has a nil value. This is not the same as saying the property can have any value though.


On Jul 6, 2005, at 9:06 PM, Óscar Morales Vivó wrote:

Aha, so as I understand it since NSDictionary won't contain nil that means it isn't possible to create a predicate with substitution variables if any of them is nil.

I'm just a young padawan when it comes to Cocoa it seems. Should have thought of that. :P

Anyway at least I know now exactly how it behaves (and it also means I'll have to do a lot of checking for nil in my code)

Thanks for the insight.

Oscar Morales Vivo.

On Jul 6, 2005, at 23:14 , mmalcolm crawford wrote:



On Jul 6, 2005, at 5:19 PM, Óscar Morales Vivó wrote:



I've understood how to build predicates with variables, how to instantiate them and do fetch requests on them. However I'm not sure how the predicate will behave if any of the predicate's variables ends up being nil, especially for things like dates where I'm not sure how a zero would be interpreted.



Do you mean you want to use predicateWithSubstitutionVariables?

<http://developer.apple.com/documentation/Cocoa/Conceptual/ Predicates/Articles/pCreating.html#//apple_ref/doc/uid/ TP40001793-219639-BCIIHDCH>

"To create a valid predicate to evaluate against an object, you use the NSPredicate method predicateWithSubstitutionVariables: to pass in a dictionary that contains the variables to be substituted. (Note that the dictionary must contain key-value pairs for all the variables specified in the predicate.)"

(That constraint should be mentioned in the API reference...)

mmalc

_______________________________________________
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


_______________________________________________ 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
References: 
 >NSPredicate and nil variables. (From: Óscar Morales Vivó <email@hidden>)
 >Re: NSPredicate and nil variables. (From: mmalcolm crawford <email@hidden>)
 >Re: NSPredicate and nil variables. (From: Óscar Morales Vivó <email@hidden>)

  • Prev by Date: Re: A Framework for a source-code editor ?
  • Next by Date: Best cocoa interface for serial
  • Previous by thread: Re: NSPredicate and nil variables.
  • Next by thread: Best cocoa interface for serial
  • Index(es):
    • Date
    • Thread