Re: Fetch Requests and NSDecimalNumbers
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