Re: NSViewController's representedObject and NSArrayController's selection don't mix?
Re: NSViewController's representedObject and NSArrayController's selection don't mix?
- Subject: Re: NSViewController's representedObject and NSArrayController's selection don't mix?
- From: Jacob Lukas <email@hidden>
- Date: Mon, 7 Apr 2008 14:58:00 -0400
- Resent-date: Mon, 7 Apr 2008 15:05:24 -0400
- Resent-from: Jacob Lukas <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: Apple Cocoa List <email@hidden>
In diagnosing this problem, I tried to use the
NSKeyValueObservingOptionPrior when observing NSArrayController's
selection, but I never got a
observeValueForKeyPath:ofObject:change:context: where the change
dictionary contained an NSKeyValueChangeNotificationIsPriorKey entry.
This leads me to believe that the issue is being caused by the
selection proxy object's target is getting changed before I (or KVO)
get any notification of the change.
I've worked around this issue by setting the NSViewController's
representedObject to nil in the table delegate method
tableView:shouldSelectRow: and set it back to -[NSArrayController
selection] in tableViewSelectionDidChange:. This works, but flashes to
blank before changing to the new value. I tried NSDisableScreenUpdates/
NSEnableScreenUpdates, which reduced the flash length, but didn't
remove it. Is there a better way to do what I'm trying to do?
Thank you,
Jacob Lukas
On Apr 6, 2008, at 22:52, Jacob Lukas wrote:
I have a table of Core Data objects and a set of inspector views.
Depending on the Class(es) of the selection in the table view, the
set of inspector views changes.
I managed the inspector views with NSViewControllers. The fields in
the inspector view are bound to the view controller's
representedObject -- ex. representedObject.radius. This works, but
when I add a deeper path to the mix (ex.
representedObject.material.refractionIndex), I get the following
message in the console when the selection changes:
2008-04-06 22:35:40.095 RayT[14429:10b] Cannot remove an observer
<NSKeyValueObservance 0x11434b1c0> for the key path
"material.refractionIndex" from <_NSControllerObjectProxy
0x114329b30>, most likely because the value for the key "material"
has changed without an appropriate KVO notification being sent.
Check the KVO-compliance of the _NSControllerObjectProxy class.
The first selection works, but each selection change after that
trigger this message.
Since the applicable inspector views change, I set their
representedObject just before adding them to the screen:
[controllers
makeObjectsPerformSelector:@selector(setRepresentedObject:)
withObject:[configController selection]];
Where controllers is the list of inspector views and
configController is the array controller. If I precede this by first
setting the representedObject to nil, I get the message every other
selection event, rather than every event.
Can anyone help shed some light on this situation?
Thank you,
Jacob Lukas
_______________________________________________
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