• 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: awakeFromInsert called twice with nested contexts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: awakeFromInsert called twice with nested contexts


  • Subject: Re: awakeFromInsert called twice with nested contexts
  • From: Roland King <email@hidden>
  • Date: Sun, 20 Nov 2011 09:49:10 +0800

On Nov 20, 2011, at 5:48 AM, Jerry Krinock wrote:

>
> On 2011 Nov 16, at 17:16, Tom Harrington wrote:
>
>> I'm finding that if I use nested managed object contexts,
>> awakeFromInsert will be called twice on new objects.
>
>> I'm wondering if this is a Core Data bug or a documentation bug.
>
> I'd say it's a pretty serious Core Data bug.  I've not had an occasion to use nested managed object contexts yet, but I put things in -awakeFromInsert that I only want to happen once.
>

It's certainly not explicitly documented, however a quick scan of the iOS forums finds another 3 developers who've discovered the same thing. Is it really the same object however? It can't be, right, they have different addresses, so Core Data is arguably doing what the documentation says, it's calling awakeFromInsert only once in the object's lifetime, you just have two objects, one in each context.

What does the object look like when you get the second call? Has Core Data literally just created it in the second MOC and is calling awakeFromInsert on it before (I assume) populating the data on it from the original, or is it already a clone of the first, with properties and relationships set on it? If the former that seems not too inconsistent, new object in new store gets called to set up defaults before the properties you set on it are cloned over, if the second case, that's much harder to deal with (and sounds like a bug)



_______________________________________________

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: awakeFromInsert called twice with nested contexts
      • From: Tom Harrington <email@hidden>
References: 
 >awakeFromInsert called twice with nested contexts (From: Tom Harrington <email@hidden>)
 >Re: awakeFromInsert called twice with nested contexts (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Is MKMapView just kinda messy?
  • Next by Date: Re: NSTableView and scrollToPoint:
  • Previous by thread: Re: awakeFromInsert called twice with nested contexts
  • Next by thread: Re: awakeFromInsert called twice with nested contexts
  • Index(es):
    • Date
    • Thread