• 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: Fetch Requests and NSDecimalNumbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fetch Requests and NSDecimalNumbers


  • Subject: Re: Fetch Requests and NSDecimalNumbers
  • From: mmalcolm crawford <email@hidden>
  • Date: Thu, 23 Feb 2006 11:50:07 -0800


On Feb 23, 2006, at 11:05 AM, Steve Cronin wrote:

If totalCost is an attribute of type NSDecimalNumber, how do I best, and most efficiently, express a predicate that implements:
totalCost > $USER_SUPPLIED_VARIABLE


It's not clear what's bamboozling?


NSPredicate *predicate = [NSPredicate predicateWithFormat:@"totalCost > %@", userSuppliedVariable];


or (if you want to create a template into which to substitute values -- this is more efficient if you re-use the same form of the predicate, since the format string doesn't have to be re-parsed each time):

NSPredicate *predicateTemplate = [NSPredicate predicateWithFormat:
	@"totalCost > $USER_SUPPLIED_VARIABLE"];

// ...

NSPredicate *predicate = [predicateTemplate predicateWithSubstitutionVariables:

[NSDictionary dictionaryWithObject: userSuppliedVariable forKey:@"USER_SUPPLIED_VARIABLE"]];


<http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/ Articles/pCreating.html>



See also <http://developer.apple.com/documentation/Cocoa/Conceptual/ Predicates/Articles/pUsing.html#//apple_ref/doc/uid/TP40001794- DontLinkElementID_12>.


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


References: 
 >Fetch Requests and NSDecimalNumbers (From: Steve Cronin <email@hidden>)

  • Prev by Date: Re: Displaying Only Readable/Writable Directory on NSOpenPanel
  • Next by Date: Re: Working with modem
  • Previous by thread: Fetch Requests and NSDecimalNumbers
  • Next by thread: Addendum: Fetch Requests and NSDecimalNumbers --> Fetch on Transient Values
  • Index(es):
    • Date
    • Thread