Re: NSTableView solution feedback and questions
Re: NSTableView solution feedback and questions
- Subject: Re: NSTableView solution feedback and questions
- From: Jeff LaMarche <email@hidden>
- Date: Tue, 18 Mar 2008 13:25:42 -0400
Jay:
Well, I've never had this particular situation, but you could try
registering for textDidBeginEditing) notification from the table view,
then your code will have a way of knowing when the user is editing a
table. If it's currently being edited when your timer method starts to
do an update, you could use the editedColumn and editedRow methods to
determine if the cell being edited is the one you need to update and
hold off on doing the reloadData method until after they finish
editing (you can use the textDidEndEditing for that one).
If the update is in the row they are editing, then you need to figure
out how to deal with that, it's going to be specific to your
application. You might present them with a sheet that tells them what
the update is and let them choose which one to keep.
Hope this helps.
Jeff
On Mar 18, 2008, at 1:17 PM, Jay Martin 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.
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