Re: CoreData headaches
Re: CoreData headaches
- Subject: Re: CoreData headaches
- From: Jens Alfke <email@hidden>
- Date: Fri, 28 Oct 2016 11:37:37 -0700
> On Oct 27, 2016, at 8:49 PM, Dave Fernandes <email@hidden> wrote:
>
> But what managed object are you dealing with? Is the Asset a managed object? If so, you can only access its properties from the queue of its managed object context. So if it is a main queue context, you can only access the MO’s properties from the main queue.
Amen, brother. I design/work on a storage framework with similar thread-safety rules (Couchbase Lite) and I can attest that quite a few Cocoa app developers seem to add concurrency to their code without giving it enough thought. I’ve helped people troubleshoot code where it seems like they just went “this operation is blocking the UI so I’ll just use dispatch_async to do it in the background”, without understanding the implications for race conditions, or following the thread-safety rules of the APIs they’re calling.
I’m not saying that you did this, Steve! Just using this thread as a reminder to people that Concurrency is Hard, and you have to think carefully about what you’re doing. If you aren’t very aware of what queue/thread every part of your code can run on, and what data might be accessible to other queues/threads, you’re likely to find yourself in a world of pain at some point.
—Jens
_______________________________________________
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