• 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: Creating a managed object without adding it to the context?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a managed object without adding it to the context?


  • Subject: Re: Creating a managed object without adding it to the context?
  • From: "Sean McBride" <email@hidden>
  • Date: Mon, 26 Jan 2009 14:30:56 -0500
  • Organization: Rogue Research Inc.

On 1/26/09 12:21 PM, Ulai Beekam said:

>> IIRC that happens when you insert the object directly into the managed
>> object context without going through the array controller.
>>
>> I.e. by using NSManagedObject's
>>
>> -initWithEntity:insertIntoManagedObjectContext:
>>
>> instead of NSArrayController's
>>
>> -addObject:
>
>This is actually what I'm most interested about, and the reason why I
>asked my question in the first place. Can someone else here confirm
>this? Let me repeat what is to be confirmed: When a new managed object
>is added to the managed object context (NB: Directly going through to
>the context and NOT using arrayController's add: methods), is it true
>that the arrayController will not select that particular object?
>
>If this is true, it seems strange to me, as this new object will get
>propagated to the arrayController and hence the arrayController should
>detect that it is a newly added object and therefore select it
>automatically, right?
>
>Remember that throughout this discussion we assume that the "select on
>insert" checkbox is checked for the arrayController.

I know what you're talking about.  You want to create a new object, you
want it to appear in the table, you want it to be selected, and you also
need to set some attributes/relationships that you cannot in awakeFromInsert.

The problem is that NSArrayController's -addObject: does not return to
you the pointer to the new managedobject, and so you cannot customise
it.  OTOH, if you use -initWithEntity:insertIntoManagedObjectContext:,
then it won't be selected in the arraycontroller/table.

I have been looking for the best solution for some time now.

Here's something I read recently on the topic:
<http://boredzo.org/blog/archives/2008-11-26/how-to-work-with-a-bound-to-
array>

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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

References: 
 >Creating a managed object without adding it to the context? (From: Ulai Beekam <email@hidden>)
 >Re: Creating a managed object without adding it to the context? (From: Jerry Krinock <email@hidden>)
 >RE: Creating a managed object without adding it to the context? (From: Ulai Beekam <email@hidden>)
 >Re: Creating a managed object without adding it to the context? (From: Andreas Mayer <email@hidden>)
 >RE: Creating a managed object without adding it to the context? (From: Ulai Beekam <email@hidden>)

  • Prev by Date: Re: Knowing when a NSArrayController is ready
  • Next by Date: get the drawing text height
  • Previous by thread: RE: Creating a managed object without adding it to the context?
  • Next by thread: Re: Creating a managed object without adding it to the context?
  • Index(es):
    • Date
    • Thread