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

     drewmccorm...@mentalfaculty.com
     www.mentalfaculty.com

_______________________________________________

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