Sorry for the confusion. English is not my natural language and it's been a long week :-) Also the subject should really be about synchronizing data in the table view with a database back-end. This the "tracking changes" I need to work on.

I'll try to make this clearer. As an analogy, let's say my form is like an invoice except that is often modified by the user. The user can add, update or delete rows in the UI and I need to update these changes to the database at the commit phase (when the user press the OK button). I need to identify what the user did to be able to reflect theses changes back to the database. If the user delete a row, I need to remove it from the table view and track this action somehow to update the back-end later. Same for adding or updating rows.

Hope I'm less confuse with this message. Can't do much about my English though...

Thanks for your reply Graham,

Andre Masse


On Oct 31, 2008, at 19:11, Graham Cox wrote:


To be honest I can hardly follow this at all.

You say:

I have a datasource for an NSTableView which is a NSMutableArray

This can't be, since NSMutableArray doesn't implement the NSTableDataSource protocol. So what I'm assuming you've actually got is a controller in between the two. That being the case, your controller should do the work. When the user adds a row, the controller adds the row to the data model and updates the table. If the data is updated, the controller notices the change (using some means, notifications or KVO for example) and updates the table.. and so on. It's standard MVC and highly applicable in most cases of a table hooked to an array. You could use NSArrayController to give you much of this for free.

Your situation *may* be more complicated - you certainly made it sound complicated - but is it?

n.b. if you're concerned about discovering what changed between one array and another, a possible easy way to do this is to create a NSSet from each one and subtract them.

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to