> On Dec 24, 2013, at 11:41 , Trygve Inda <[email protected]> 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. >
I am thinking that when entering into edit mode, I prevent items from being added to the array - just adding them to a temp holding array in the meantime and then adding them to the real array when the edit finishes. The reloading seem to kill the edit session no matter what I do. _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
