Core Data concurrency during import of folder contents
Core Data concurrency during import of folder contents
- Subject: Core Data concurrency during import of folder contents
- From: Steve Mills <email@hidden>
- Date: Fri, 30 Jan 2015 11:20:56 -0600
I'm trying to learn Core Data. I have a working document model hooked up to a table view (OS X). I have an import method that uses FSDirectoryEnumerator to add an object for each file in the folder. Oky doke! But that blocks for a few seconds while it loops. So I'm trying to make it threaded. One example I saw uses GCD. It kinda seemed to work when I had a bunch of printfs in there so I could watch it progress, but when I took them out it just crashed at some point, and it still blocked any sort of user events.
Next I tried sticking the entire import operation into a block via NSOperationQueue's addOperationWithBlock:. That throws because some set was being changed by multiple threads. Then I tried the suggestion of using a private NSManagedObjectContext in the block. That got me somewhere, but of course the data didn't populate my table. I tried the NSManagedObjectContextDidSaveNotification trick, but I couldn't get that to work.
Reading the Concurrency with Core Data page online says the information is outdated. Where do I find current documentation? Or better yet, an actual example that actually works? My brain is about to explode, and nobody wants to clean that up.
--
Steve Mills
Drummer, Mac geek
_______________________________________________
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