• 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: Core data fetch and multithreading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core data fetch and multithreading


  • Subject: Re: Core data fetch and multithreading
  • From: Chris Hanson <email@hidden>
  • Date: Tue, 23 Nov 2010 20:53:15 -0800

On Nov 23, 2010, at 12:38 PM, vincent habchi <email@hidden> wrote:

> However, I have now a repeated memory management crash when I release the moc (apparently, one managed object get released one time too much: it is destroyed in the main MOC, while the secondary MOC has a copy of it. When I release the secondary MOC, it sends somehow an autorelease message to the destroyed entity and that leads to a crash).
>
> Wherefore the question I asked to Quincey, that I'm repeating here:
>
> If I have two MOCs, let's say MOC1, MOC2, and I get in MOC2 the copy of a MOC1 object:
>
> Entity * entityInMOC2 = [MOC2 objectWithID:[entityInMOC1 objectID]];
>
> and then I traverse a relationship (or execute a fetch request):
>
> OtherEntity * someOtherEntity = [entityInMOC2 someRelationship];
>
> do the variable someOtherEntity refer to an object in MOC1 or in MOC2?

The variable someOtherEntity refers to an object in the same context as entityInMOC2, therefore MOC2.

I think I see where your issue is though. On this line:

> Entity * entityInMOC2 = [MOC2 objectWithID:[entityInMOC1 objectID]];


If your code actually looks like this, it's a bug: You're using entityInMOC1 in another thread. Pass JUST its object ID, not the object itself, from one thread to the other.

 -- Chris

_______________________________________________

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: Core data fetch and multithreading (sequel)
      • From: vincent habchi <email@hidden>
    • Re: Core data fetch and multithreading
      • From: vincent habchi <email@hidden>
References: 
 >Core data fetch and multithreading (From: vincent habchi <email@hidden>)
 >Re: Core data fetch and multithreading (From: Chris Hanson <email@hidden>)
 >Re: Core data fetch and multithreading (From: vincent habchi <email@hidden>)

  • Prev by Date: Re: Help with Basics
  • Next by Date: Re: Core data fetch and multithreading
  • Previous by thread: Re: Core data fetch and multithreading
  • Next by thread: Re: Core data fetch and multithreading
  • Index(es):
    • Date
    • Thread