executeFetchRequest with BETWEEN
executeFetchRequest with BETWEEN
- Subject: executeFetchRequest with BETWEEN
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sun, 14 Feb 2010 12:08:57 +0700
I would like to get some entities (in iPhone 3.1.3). So I do:
NSNumber *sta = ...
NSLog(@" sta %@ %@ %p", sta, [sta class],sta); // sta 6 NSCFNumber 0x3b3a690
NSNumber *las = ...
NSArray *limits = [ [ NSArray alloc ] initWithObjects: sta, las, nil ];
predicate = [ NSPredicate predicateWithFormat: @"%K between %@", @"windex", limits ];
[ limits release ];
[ reques2 setPredicate: predicate ];
NSSortDescriptor *sd = [ [ NSSortDescriptor alloc ] initWithKey: @"windex" ascending: YES ];
NSArray *sortDescriptors = [ [ NSArray alloc ] initWithObjects: sd, nil ];
[ sd release ];
[ reques2 setSortDescriptors:(NSArray *)sortDescriptors ];
[ sortDescriptors release ];
NSLog(@" will executeFetchRequest %@", reques2);
// will executeFetchRequest <NSFetchRequest: 0x3d54c90> (entity: DictWord; predicate: (windex BETWEEN {6, 4842}); sortDescriptors: (
(windex, ascending, compare:)
); limit: 0)
// Note: windex is an int32 predicate of the entity DictWord
NSError *outError;
NSArray *results = [ moc executeFetchRequest: reques2 error: &outError ];
But instead of some nice results I get:
*** -[NSCFNumber constantValue]: unrecognized selector sent to instance 0x3b3a690
Note: constantValue is a message understood by NSExpression (not by NSNumber)
and 0x3b3a690 is my NSNumber sta (see above).
It seems that my predicate is wrong, but how to make it right?
Kind regards,
Gerriet.
_______________________________________________
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