NSCollectionView not safely usable with CoreData

Originator:michael.markowski
Number:rdar://9903150 Date Originated:2011/08/05
Status:Submitted Resolved:No
Product:OSX SDK Product Version:10.6
Classification:Other Bug Reproducible:Yes
 
Summary:

CoreData throws an Exception when removing NSCollectionView Items and saving while NSCollectionView is performing it's animation.

Project setup/environment: CoreData model with two entities: "Item" and "RelatedItem". "Item" has a relation to "RelatedItem". Both entities each contain two attributes: "foo" and "bar" (NSString), which are bound to the view (NSCollectionViewItem).

Steps to Reproduce:

Open attached Project or clone at https://github.com/artifacts/NSCollectionViewCoreDataBug
Hit "Add" button a couple of times. Some items will be added.
Save document under an arbitrary name.
Start clicking "Remove"-Button a couple of times and WHILE NSCollectionView IS ANIMATING hit Cmd-S to save.
Expected Results:

The document should be saved without error.

Actual Results:

CoreData could not fulfill a fault for '0x1001f40b0 x-coredata://64DE7FCC-8F74-4445-8F6F-173ECA2CB5C4/Item/p5'

Regression:

This also happens in undo/redo scenarios. E.g.: Add some items, save, remove all items, save again, undo until no more undo possible, redo, CRASH:

2011-08-05 12:28:01.942 CollectionViewCoreDataBug[73308:a0f] CoreData could not fulfill a fault for '0x1004e73a0 x-coredata://0F566CD9-715B-46EB-8E2F-66EF9CA08869/Item/p1' 2011-08-05 12:28:02.493 CollectionViewCoreDataBug[73308:a0f] CoreData could not fulfill a fault for '0x10047fc30 x-coredata://0F566CD9-715B-46EB-8E2F-66EF9CA08869/RelatedItem/p4' 2011-08-05 12:28:02.587 CollectionViewCoreDataBug[73308:a0f] Cannot remove an observer for the key path "relatedItem.bar" from , most likely because the value for the key "relatedItem" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the NSManagedObject class. 2011-08-05 12:28:02.598 CollectionViewCoreDataBug[73308:a0f] Serious application error. Exception was caught during Core Data change processing: CoreData could not fulfill a fault for '0x10047fc30 x-coredata://0F566CD9-715B-46EB-8E2F-66EF9CA08869/RelatedItem/p4' with userInfo { NSAffectedObjectsErrorKey = ( " (entity: RelatedItem; id: 0x10047fc30 x-coredata://0F566CD9-715B-46EB-8E2F-66EF9CA08869/RelatedItem/p4 ; data: )" ); }

This also happens on Lion.

Notes:

I'm not alone, see:

http://stackoverflow.com/questions/4733911/is-nscollectionview-compatible-with-coredata/6951079#6951079

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!