• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArrayController + NSTableView addObject ends editing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSArrayController + NSTableView addObject ends editing
      • From: Trygve Inda <email@hidden>
References: 
 >Re: NSArrayController + NSTableView addObject ends editing (From: Trygve Inda <email@hidden>)

  • Prev by Date: Re: iTune Plist changes from NSUserdefaults
  • Next by Date: Re: NSArrayController + NSTableView addObject ends editing
  • Previous by thread: Re: NSArrayController + NSTableView addObject ends editing
  • Next by thread: Re: NSArrayController + NSTableView addObject ends editing
  • Index(es):
    • Date
    • Thread