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: Stamenkovic Florijan <email@hidden>
- Date: Tue, 29 Sep 2009 22:09:50 -0400
On Sep 29, 2009, at 19:21, Quincey Morris wrote:
On Sep 29, 2009, at 15:27, Stamenkovic Florijan wrote:
// the group dragged to
NSManagedObject* group = [((NSTreeNode*)proposedParentItem)
representedObject];
// the URIs of Notes being dragged
NSArray* noteURIs = [NSKeyedUnarchiver
unarchiveObjectWithData:[pboard
dataForType:FSNoteIDURIsArrayPBType]];
NSUndoManager* um = [[group managedObjectContext] undoManager];
// relate the notes to the group dragged into
// do it as a single undoable op
[um beginUndoGrouping];
for(NSURL* noteURI in noteURIs){
// app delegate is the where the managed object URI -> managed
object reference logic resides
FSNote* note = (FSNote*)[appDelegate objectForURI:noteURI];
note.group = group;
}
[um endUndoGrouping];
I dunno, this is where my head starts to hurt.
According to your error message, there was an observer of a Note
(well, FSNote) object for key path "group.name".
I figured that out. And I am fairly sure it is a binding mediator
between the column and the array controller, because if I remove that
column, I don't get the error.
However, your binding is via arrangedObjects. Now, although the
array controller may be KVO compliant for the property
"arrangedObjects", the arrangedObjects array isn't itself KVO
compliant for anything, because arrays just aren't. So although
'note.group = group;' is generating the correct notification, maybe
it just isn't "flowing through" the array controller to the binding
mechanism.
Hm... I am thinking something similar. However, it seems to me that
every item in the contents of an array controller is observed for
relevant paths. Which can be witnessed when binding a table column's
value to an attribute of an item in the controller. For example,
"arrangedObjects.firstName" in a Person. So, it seems that an array
controller provides KVO compliance for it's contents (arrangedObjects)
as well as for the properties of items in that array. My situation
seems to imply this too. If I bind to "arrangedObjects.group", and use
a value transformer, I get both the correct behavior and updates in
the NSTableView resulting when I change a Note's group relationship.
Where it seems to fail is when stretching that path. Somehow the array
controller seems to be able to handle "itemNoX.relationship", but not
"itemNoX.relationship.attribute".
I'm going to take a stab in the dark and predict that you *don't*
have "rearranges content automatically" checked for the array
controller,
I do.
and that checking it will cause the error message to go away.
It does not.
(Or, equivalently, you could send a "rearrangeObjects" message to
the array controller immediately after 'note.group = group;'.)
I am not sure where you are going with this, but I have tried it, and
it does not change the behavior.
F
if nobody comes up with a "you are doing this wrong, do it like this"
by tomorrow I will try to isolate this in a small case. Maybe I am
causing this somewhere else in my code. I think not, but best to check.
_______________________________________________
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