Re: NSTableView solution feedback and questions
Re: NSTableView solution feedback and questions
- Subject: Re: NSTableView solution feedback and questions
- From: Laurent Cerveau <email@hidden>
- Date: Tue, 18 Mar 2008 18:48:54 +0100
On Mar 18, 2008, at 6:17 PM, Jay Martin <email@hidden> wrote:
All,
I'm new to Cocoa (surprise) and I'm now working on a little app, and
I've come up with a solution to an issue and I'd like some feedback
on that solution. Here's the problem description:
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.
If your data model is updated but not the Table View simply calling
setNeedsDisplay on the tv should be enough and less expensive (you can
even simply call it for rects of cells to be updated)
Laurent
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?
My second question is more general. I've basically just completed
the Cocoa Programming book by Hillegass. Is there a "next" logical
book/document to read, or is it just time to write lots of
experimental code and ask questions?
Thanks!
jay
_______________________________________________
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
_______________________________________________
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