• 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: Core Data fetch exception... further
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data fetch exception... further


  • Subject: Re: Core Data fetch exception... further
  • From: Fritz Anderson <email@hidden>
  • Date: Sun, 12 Jul 2009 14:18:40 -0500

On 12 Jul 2009, at 2:05 PM, Fritz Anderson wrote:

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?

The predicate seems to be a red herring. Commenting out "fetch.predicate = pred" does not work around the bug, nor does changing the predicate to reference another attribute.


I've already mentioned that latestDate is set up in the MOM. In my code, it's

@property(nonatomic, retain) NSDate *	latestDate;
@dynamic latestDate;

Switching from self.latestDate = to [self setPrimitiveLatestDate:] in the awake... methods had no effect.

I've verified that there is only one Sale. It has not been saved.

	— F

_______________________________________________

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


References: 
 >Core Data fetch exception: keypath <transient attribute> not found in entity (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: Printing a View
  • Next by Date: Re: [iPhone] Multi-touch gestures in table views?
  • Previous by thread: Core Data fetch exception: keypath <transient attribute> not found in entity
  • Next by thread: Re: Core Data fetch exception: keypath <transient attribute> not found in entity
  • Index(es):
    • Date
    • Thread