noob question regarding proxy object returned by -selection method of NSArrayController
noob question regarding proxy object returned by -selection method of NSArrayController
- Subject: noob question regarding proxy object returned by -selection method of NSArrayController
- From: Stuart Malin <email@hidden>
- Date: Sat, 28 Jun 2008 10:43:36 -0700
Still pursuing my understanding of bindings:
I have a table view whose columns are bound to an NSArrayController,
which in turn has its contentObject that is a mutable array of Person
objects. Person objects have KVC-conforming properties, which provide
the values for the data in the columns of the table. This all works.
I have a button in the GUI that should cause various changes to the
person selected in the table. In the method that is the target of the
button's action, I need to get the selected Person object so I can
operate on it.
I know I could use the -selection method of the NSController to get
a proxy object, and then use -valueForKey: and -setValueForKey to
operate on the object via the proxy. However, this puts the logic of
the manipulations in my appController. I'd rather the collection of
manipulations be in the Person class, (i.e., have instance methods
in the Person class that update a person object).
If I do this (have the update logic in the Person class), then I
can't use the proxy object returned by the -selection method of the
NSController (because the proxy object doesn't respond to the methods
of the backing class).
My question is: What is the best way to get the actual model entry,
so such instance methods can be invoked?
BTW: I have one solution, which is to send the controller a -
selectionIndex message, and use the resulting index to directly
access the backing store. But doing this is based on knowing what
that backing content object is, which seems like I am using side
knowledge in my appController, and so I wonder if there is a way to
get the actual model content object directly from the
NSArrayController....
_______________________________________________
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