Re: NSPredicateEditorRowTemplate for NSDate
Re: NSPredicateEditorRowTemplate for NSDate
- Subject: Re: NSPredicateEditorRowTemplate for NSDate
- From: Markus Spoettl <email@hidden>
- Date: Mon, 19 Jan 2009 22:24:32 +0100
On Jan 19, 2009, at 9:13 PM, Vitaly Ovchinnikov wrote:
Hey, boys and girls?
Am I the first, who use NSPredicateEditor?
I just found that there is no default template for time values...
I basically use this code for a date value row template (simplified
version not tested):
NSArray *operators = [NSArray arrayWithObjects:
[NSNumber numberWithInteger:NSEqualToPredicateOperatorType],
[NSNumber numberWithInteger:NSLessThanPredicateOperatorType],
[NSNumber
numberWithInteger:NSGreaterThanPredicateOperatorType],
[NSNumber
numberWithInteger:NSLessThanOrEqualToPredicateOperatorType],
[NSNumber
numberWithInteger:NSGreaterThanOrEqualToPredicateOperatorType],
nil];
NSExpression *equipmentExpr =
[NSExpression expressionForKeyPath:@"date"]; <<-- use the key
path appropriate for your object
NSPredicateEditorRowTemplate *dateTemplate =
[[[NSPredicateEditorRowTemplate alloc]
initWithLeftExpressions:expressions
rightExpressionAttributeType:NSDateAttributeType
modifier:NSDirectPredicateModifier
operators:operators
options:0] autorelease];
NSArray *templates = [NSArray arrayWithObjects:
...
dateTemplate,
...
nil];
[editor setRowTemplates:templates]; <<-- editor is a
NSPredicateEditor ivar
All is needed now is a predicate that matches the templates you
defined and it should work. If you give the editor a predicate it
cannot resolve using the row template you will get a console log entry
telling you details (at least on Leopard).
Hope this helps!
Regards
Markus
--
__________________________________________
Markus Spoettl
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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