Re: NSTableColumn value binding + keypath over a relationship
Re: NSTableColumn value binding + keypath over a relationship
- Subject: Re: NSTableColumn value binding + keypath over a relationship
- From: Quincey Morris <email@hidden>
- Date: Tue, 29 Sep 2009 14:44:47 -0700
On Sep 29, 2009, at 14:18, Stamenkovic Florijan wrote:
A CoreData app. I have a table and one of it's columns' value bound
to an array controller's "arrangedObjects.group.title". The
controller contains objects of the Note entity. Note relates to a
Group (to-one), and the Group entity has a "title" attribute.
Straightforward. Next to the table I have an outline view containing
Groups. I have implemented drag and drop so that Notes can be
dragged from their table to a different group in the outline view.
However, when I have the above described table column present in the
table, I get an error after dragging that says:
Cannot remove an observer <NSTableBinder 0x177eb0> for the key path "group.name
" from <FSNote 0x1ad240>, most likely because the value for the key
"group" has changed without an appropriate KVO notification being
sent. Check the KVO-compliance of the FSNote class.
I am quite certain that the Note class is KVO compliant for "group",
since I don't do anything to prevent it being, and it's a CoreData
entity with @dynamic property generation.
So, I am wondering, am I doing something wrong? It seems a
reasonable thing to do, binding a column's value to the
"arrangedObjects.relationship.attribute" key path, but maybe that is
not allowed?
The error message specifies "group.name", not "group.title". Do you
maybe have a typo in one of your bindings in IB?
KVO compliance doesn't necessarily come automatically, if you "don't
do anything to prevent it". In the case of a simple property, yes,
*if* you update the property through the proper setter, the KVO
notifications will occur automatically, but it's easy to get into a
situation where the update doesn't happen when or as you think. It
only gets more complicated when key paths are involved, instead of
single keys.
Also, keep in mind that a path like "arrangedObjects.group.title" is a
fiction. arrangedObjects is an array, and each row of the column is
bound to a different element of the array. "arrangedObjects" is the
key path to the array property, "group.title" is the key path to each
element. The binding is what bridges that difference -- there is more
going on behind the scenes than just KVC.
(Because of convenience behavior in NSArray, a key path like
"someArray.somePropertyOfEachArrayElement" will actually return an
array of property values when accessed via KVC, but that reference is
not in itself KVO compliant.)
_______________________________________________
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