Persistent store removal throwing invalidated NSManagedObject exceptions
Persistent store removal throwing invalidated NSManagedObject exceptions
- Subject: Persistent store removal throwing invalidated NSManagedObject exceptions
- From: Drew McCormack <email@hidden>
- Date: Wed, 01 Apr 2009 11:20:48 +0200
- Resent-date: Wed, 01 Apr 2009 11:28:14 +0200
- Resent-from: Drew McCormack <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
I've setup a temporary managed object context to export data to an
external XML file (persistent store). When I remove the persistent
store from the context, I am getting errors like this:
Exception raised during posting of notification. Ignored. exception:
'The NSManagedObject with ID:0x18656990 <x-coredata://2E9A390F-BA42-48E7-847A-EAB4E11CCCF1/CollectionGroup/p104
> has been invalidated.' invoked observer method: '*** -
[NSManagedObjectContext _storeConfigurationChanged:]' observer:
0x1864d370 notification name:
'_NSPersistentStoreCoordinatorStoresDidChangePrivateNotification'
The managed object subclass causing the issue is one that uses KVO to
follow changes in other objects.
I've tracked the notification down to one KVC method for a core data
relationship property called 'collections'.
-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
[anObject removeObserver:self forKeyPath:@"knowledgeItems"];
[self willChangeValueForKey:@"collections"];
[[self primitiveValueForKey:@"collections"] removeObject:anObject];
[self didChangeValueForKey:@"collections"];
[self refresh];
}
This has been included to remove the object as a KVO observer, and
refresh a lazy property, but actually, the notification also arises
when I just use this
-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
[self willChangeValueForKey:@"collections"];
[[self primitiveValueForKey:@"collections"] removeObject:anObject];
[self didChangeValueForKey:@"collections"];
}
If I remove the method altogether, the exception does not get raised.
So I'm confused, because I would have thought that the implementation
above would be pretty much the same as what Core Data would do
internally if the method is not included. Apparently it is doing other
things to
avoid the exception, but what?
Drew
____________________________________
Drew McCormack
Chief Developer
The Mental Faculty
email@hidden
www.mentalfaculty.com
_______________________________________________
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