Re: CoreData headaches
Re: CoreData headaches
- Subject: Re: CoreData headaches
- From: Steve Mills <email@hidden>
- Date: Fri, 28 Oct 2016 20:20:23 +0000 (GMT)
On Oct 28, 2016, at 01:37 PM, Jens Alfke <email@hidden> wrote:
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.
No, I'm sure I *would* do something like that. :) To me, the CoreData docs are just a pile of confusion with no human explanation that I can understand. Maybe I should read it again to see if it's been improved recently. Or, more likely, I glossed over reading that part back when I started with CoreData because IKImageBrowserView took care of creating thumbnails for me, so crap just worked.
Sent from iCloud's ridiculous UI, so, sorry about the formatting
_______________________________________________
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