• 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: Array Controller "Select Inserted Objects" [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array Controller "Select Inserted Objects" [SOLVED]


  • Subject: Re: Array Controller "Select Inserted Objects" [SOLVED]
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 1 Jan 2010 21:12:55 -0800

On 2009 Dec 05, at 22:43, Jerry Krinock wrote:

> I tested a new build of an app today and found that, all of a sudden, clicking the "+" button for a table view adds a new object but no longer selects it.

The problem was that I was invoking the array controller's -newObject, *then* inserting it with

[arrayController insertObject:newObject
        atArrangedObjectIndex:([arrayController selectionIndex] + 1) ;

I didn't realize that -newObject had already inserted, so the effect this was to insert the same object into the content array twice.  Now I guess that when the Core Data model KVOed this view change, it registered a set containing only unique object, apparently the one that was not selected, and then when the array controller KVOed this model change, it deleted the one that was selected.  Very cute.

So, have no doubts about NSArrayController's "Select Inserted Objects".  It works.

_______________________________________________

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: Array Controller "Select Inserted Objects" [SOLVED]
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: NSImage
  • Next by Date: Re: Setting the Line Height/ Line Spacing in an NSTextView.
  • Previous by thread: Re: NS_INLINE and obj = nil;?
  • Next by thread: Re: Array Controller "Select Inserted Objects" [SOLVED]
  • Index(es):
    • Date
    • Thread