Bindings Problem: KVO Not Being triggered?
Bindings Problem: KVO Not Being triggered?
- Subject: Bindings Problem: KVO Not Being triggered?
- From: Keary Suska <email@hidden>
- Date: Wed, 23 Aug 2006 13:27:21 -0600
- Thread-topic: Bindings Problem: KVO Not Being triggered?
I came across an odd binding problem. I have a kind of master-detail binding
interface, except that the master-detail connection is manually triggered
(i.e. not bound). The problem is that changes made in an apparently KVC/O
compliant way are not propagated to the NSObjectController, and it will not
update its content object even when told. Let me explain--and please bear
with the excessive detail--I ma trying to provide enough to facilitate an
answer.
I have a tableview bound to an arraycontroller subclass, whose content is
bound to an object that maintains its array. When a row is double-clicked an
action is triggered in the arraycontroller that sets an objectcontroller
subclass' content (-setContent:) and open a modal window with field values
bound to the objectcontroller. All editing occurs here. The content of the
objectcontroller is a class that overrides -setValue:forUndefinedKey: to
allow transparent access to an NSMutableDictionary that the class maintains.
This works flawlessly, or almost.
All is well. Edits made are propagated to the content object and the
arraycontroller as expected. However, edits made must be saved/or canceled,
and when the cancel button is hit (action in objectcontroller) the code (of
the content object) changes the content values back to their original,
pre-edited values using -setValue:forKey and the window is closed. The
values reflected in the tableview revert as expected.
The problem appears when the same table row is double clicked. Even though
the objectcontroller is being sent content, the content doesn't update--i.e.
Shows the last edited values. If I open a different row, then go back to the
edited row, the values show correctly. First off, this seems to indicate
that KVO is not being triggered for the objectcontroller, even though it is
for the arraycontroller.
I implemented a work-around where I set the objectcontroller content to nil
before setting the content object, and this works fine. It seems as if the
-setContent: method checks to see if the pointers match, and doesn't change
if it does (perhaps an optimization), which wouldn't be an issue if the
objectcontroller would update its values when told.
Hope this is enough info. Any ideas?
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden