[SOLVED] Re: NSViewController's representedObject and NSArrayController's selection don't mix?
[SOLVED] Re: NSViewController's representedObject and NSArrayController's selection don't mix?
- Subject: [SOLVED] Re: NSViewController's representedObject and NSArrayController's selection don't mix?
- From: Jacob Lukas <email@hidden>
- Date: Mon, 7 Apr 2008 19:25:08 -0400
The problem ended up being that the object returned by -
[NSArrayController selection] is a private proxy object, which
dynamically proxies the current selection of the array controller.
This means that the views were trying to stop observing the current
selection's relationships, rather than the previous selection's
relationships.
Since I wanted the NSMultipleValuesMaker behavior provided by the
private proxy, I ended up solving this problem by implementing a proxy
object that proxies to an array. I then gave the selectedObjects to
this proxy object, and set the proxy as my view controller's
representedObject each time the selection changes. This works
beautifully.
If anyone wants the source for my proxy class, I'd be happy to provide
it (free for all use).
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