Re: NSArrayController + NSTableView addObject ends editing
Re: NSArrayController + NSTableView addObject ends editing
- Subject: Re: NSArrayController + NSTableView addObject ends editing
- From: Quincey Morris <email@hidden>
- Date: Tue, 24 Dec 2013 12:14:26 -0800
On Dec 24, 2013, at 11:41 , Trygve Inda <email@hidden> wrote:
> It seems that NSTableView's reloadData called by NSArrayController's
> addObject kills the edit session (without giving my delegate a chance to
> refuse to end the editing).
>
> Is there a way to add items to the table and not end my editing?
Which addObject?
If you’re relying on, ‘addObject:’, then I’d suggest you try ‘addObject:atArrangedObjectIndex:’.
If you’re already using ‘addObject:atArrangedObjectIndex:’ or can’t/don’t want to use it, then I’d suggest you try updating the data model directly and KVO compliantly.
The problem with ‘addObject:’ is that it’s a fairly blunt instrument, and it doesn’t run immediately anyway.
If you use one of the other techniques, then the array controller will see a KVO update for the insertion. Depending on how cleverly it handles that, it might not cause editing to end.
If none of that works, then the next place to fall back would be to eliminate the array controller and provide a data source instead. However, after inserting an object into the data model, you will still need to *either* call ‘reloadDataForRowIndexes:columnIndexes:’ *or* ‘insertRowsAtIndexes:withAnimation:’, depending on what OS X version you’re targeting.
Even then, I wouldn’t assume that those methods preserve the editing state without trying it.
_______________________________________________
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