Re: Array Controller "Select Inserted Objects" [SOLVED]
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