Core Data : Save As : Object temporarily missing in fetch results
Core Data : Save As : Object temporarily missing in fetch results
- Subject: Core Data : Save As : Object temporarily missing in fetch results
- From: Jerry Krinock <email@hidden>
- Date: Thu, 1 Jul 2010 15:38:35 -0700
I'm debugging a problem with Save As in a Core Data document, and I'm not sure if the following is part of the main show, or a sideshow.
A document contains only one object in a given entity. I've written a little debugger method which simply fetches all objects of a given entity and logs the result. [1]
Before my Save As operation, running this method logs an array of one object, as expected. But after the Save As, it logs an empty array (empty fetch). But wait, if I then change an attribute of the "missing" object, using the app's GUI, and re-run this logging method, the object reappears in the new fetch result. And it has the same pointer address and permanent objectID as before. And its -isFault and -isDeleted are both NO, both before and after its dis/reappearance.
Is there any Core Data behavior that might explain this?
Jerry
[1] This is in a window controller subclass.
- (void)debugLogObjectsEntityName:(NSString*)entityName {
NSManagedObjectContext* moc = [[self document] managedObjectContext] ;
[moc processPendingChanges] ; // Has no effect.
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init] ;
NSArray* fetches = nil ;
if (moc) {
[fetchRequest setEntity:[NSEntityDescription entityForName:entityName
inManagedObjectContext:moc]] ;
fetches = [moc executeFetchRequest:fetchRequest
error:NULL] ;
}
[fetchRequest release] ;
NSLog(@"This doc contains %d objects of entity %@:\n%@",
[fetches count],
entityName,
[fetches shortDescription]) ;
// -shortDescription is a method I've written to give pertinent info
// about managed objects and collections of managed objects, without
// filling the console/screen like -[NSManagedObject description] does.
}_______________________________________________
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