This is on iPhone 3.0, but should be of general applicability.

I have an entity, "Sale," that has a transient attribute "latestDate." It is marked optional/transient/indexed in the MOM; I've also tried it without setting optional. I set latestDate in awakeFromFetch and awakeFromInsert. I use [NSDate dateWithTimeIntervalSinceReferenceDate: 0] as a flag value.

At some point in my application, I want to retrieve all Sales that don't have that flag value. I do:

=====
NSFetchRequest *        fetch = [[NSFetchRequest alloc] init];
fetch.entity = [NSEntityDescription entityForName: @"Sale"
                           inManagedObjectContext: gMoc];
NSSortDescriptor * sort = [[NSSortDescriptor alloc] initWithKey: @"latestDate"
                                                          ascending: NO];
fetch.sortDescriptors = [NSArray arrayWithObject: sort];
[sort release]; 
NSPredicate * pred = [NSPredicate predicateWithFormat: @"latestDate ! = %@",
                                        [NSDate 
dateWithTimeIntervalSinceReferenceDate: 0]];
fetch.predicate = pred;
NSError *               error = nil;
NSArray *               retval = [gMoc executeFetchRequest: fetch error: 
&error];
=====

The execute... method raises
'NSInvalidArgumentException', reason: 'keypath latestDate not found in entity <NSSQLEntity Sale id=2>'

Only one Sale object is in the MOC. awakeFromInsert was called on it before this fetch is executed. I've searched my project for regular expressions that should catch most possible misspellings.

This is surely a rookie mistake, but I'm out of ideas. What am I doing wrong?

        — F_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to