Re: NSTableView solution feedback and questions
Re: NSTableView solution feedback and questions
- Subject: Re: NSTableView solution feedback and questions
- From: Quincey Morris <email@hidden>
- Date: Tue, 18 Mar 2008 11:34:07 -0700
On Mar 18, 2008, at 10:17, Jay Martin wrote:
I have an NSTableView, bound to an NSArrayController, which is bound
to my custom object. So far so good. I can change attributes, add,
remove, all that good stuff. Now, my custom object can have one
property changed programmatically by an NSTimer. Of course, when the
change happens, the object is updated but not the NSTableView.
So, I implemented a notification in the set method for that
property, and registered a notification listener in my app
controller. Now, when the app controller sees the update to that
property, it calls reloadData method on the NSTableView. That seems
to work nicely.
Except one thing: if I'm in the middle of editing a different row
when the NSTableView:reloadData method is called, the editing is
ended. One obvious way around this is to not allow in-line editing
of the data in the table, but rather in a separate set of controls
for the object for the selected row. That's where I am currently.
So, my first question is, am I missing something fundamental here?
Is this the "right" way of doing it, or is there a better way? I
thought maybe KVO might be a solution, but it didn't really seem
appropriate to this situation. I suppose you could try to manually
update just the cell, right?
If I understand this right, you shouldn't be calling reloadData at all.
The array controller "watches" the table column properties for free.
That's what it's for. Or rather, the table view watches the array
controller, and the array controller watches the object it's bound to.
So long as that object is KVC-compliant for the property, it should
show up in the table automatically whenever it is set, from whatever
source.
What are the specific bindings you're using here?
Presumably the table column is bound to the array controller's
selection with key propertyName.
Presumably the array controller is bound to the app controller as
File's Owner with key ... what? No key, or customObject?
My guess is you've bound the array controller to the app controller,
and the app controller isn't KVC-compliant for its key, even though
the custom object is for its key.
_______________________________________________
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