• 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: vincent habchi <email@hidden>
  • Date: Tue, 23 Nov 2010 21:38:39 +0100

Chris,

thanks for your answer.

> Don't do this.  If you're using bindings or KVO at all in your main thread, you CANNOT lock your context every place you need to in order to make this safe. Furthermore, I suspect you may not be locking your context on the background thread because you're "just reading" - that's also incorrect.

I don't use bindings and lock also on the background thread, but I followed the general advice, threw this code away and replaced it by a dual MOC, one on the main thread, and the other one being created at the beginning of the GCD block, and released at the end.

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?

Thanks a lot,
Vincent_______________________________________________

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

  • Prev by Date: Re: CFRunLoopRun() and processing posix signals
  • Next by Date: Making a Label (NSTextField) clickable
  • Previous by thread: Re: Core data fetch and multithreading
  • Next by thread: Re: Core data fetch and multithreading
  • Index(es):
    • Date
    • Thread