On Mar 25, 2010, at 11:36, Joanna Carter wrote:

> My rubbish example was to demonstrate that you might want to access the 
> object that is the content of an NSObjectController, as that my be the only 
> way to determine which object is being edited.

So we're hypothesizing that there's some code that calls 'setContent:' on the 
NSObjectController to switch between different objects*? And some other code 
that needs to know when the "current" object has been edited? If so ...

I'd prefer to just KVO-observe all the properties that could be changed by 
editing, and react to the KVO notifications. That way I don't have to know what 
the editing mechanism is, because I don't care.

Or, I'd prefer to give my File's Owner object a "currentObject" property and 
bind the object controller to that.

Or, if circumstances preclude either of these approaches, I'd probably invoke 
the "last resort" clause and ask the object controller for its content.


* It doesn't really change the answer, but that's not how I use object 
controllers anyway. Instead of switching the content object, I just bind the 
object controller to the data model (or to, say, a window controller that 
provide a suitable set of properties based on the data model), and use a "model 
key" when binding a UI element to the object controller.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to