Hi, I have been building a core data application to administrate some data and I've been stumped by a bug that indicates my objects aren't KVO compliant. However, I haven't modified the default KVO compliance of the NSManagedObject, and now I'm left scratching my head.
The area of the application that the bug is affecting is that of creating some categories and organising some items that will live inside those categories. The items may exist in multiple categories and the items AND categories view order can be set by the user. Simple stuff.
To better visualise this, the key pieces of the core data model I have set-up are displayed below. I've simplified the naming and attributes of the entities somewhat:
Category <--------->> CategoryItem <<---------> Item
-------- ------------ --------
name viewPosition name
viewPosition description
This model is connected to two ArrayControllers in interface builder, one for categories and one for categoryitems. The categoryitems content set is set to the category array controller via a selection.categoryItems binding. These array controllers feed two table views. The content of the category items table is bound to the CategoryItem A.C controller via arrangedObjects.item.name.
This all works perfectly and I'm dragging and dropping and ordering both Items and Categories to my hearts desire.
Except for one strange case.
Whenever I create a category with exactly one item, then save, if I then re-open the document I am presented with the following error:
Cannot remove an observer <NSTableBinder 0x1627f670>
for the key path "item.name" from <NSManagedObject 0x16273380>
, most likely because the value for the key "item" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the NSManagedObject class.
After that the interface seems to fall apart and the application becomes unusable. I've searched the web and all I can uncover is that this points to KVC non-compliance. But I'm using standard, barely modified, Apple classes here.
The bug ISN'T raised when I bind to the viewPosition of the CategoryItem only. i.e. via arrangedObjects.viewPosition instead of arrangedObjects.item.name. It's as if the relationship between categoryitem and item isn't ready at the point the table initially observes (and only if there is one item).
Has anyone else encountered this? Can anyone think of a possible workaround?