![]() | Core data and NSOperations |
|
16 Feb 2013, 21:26
Tim West (4 posts) |
Your chapter on core data and threading is very helpful and has helped me get my own import functions running in the background. But I am confused because in your code examples you add the mail and the import operations to the main queue. So you are still blocking the main queue when you run the operations. I have had luck with using the following to setup and run things in the background – but I am wondering if there are some implications that I am not aware of that will make this fail:
My import takes about 30 seconds to create 700 objects so I dont want to block the main queue. To let the main queue update the UI as data is getting imported I issue a save from my import operation every 40 entries. Thanks |
|
18 Feb 2013, 16:47
Marcus S. Zarra (239 posts) |
The However if you are using That is why I can use that convenience method and why it is there. |
|
19 Feb 2013, 04:10
Tim West (4 posts) |
Thanks for the response – that may work well on the mac but on the iPhone I get: DLog(@”Number of threads on mainQueue %d”, [[NSOperationQueue mainQueue] maxConcurrentOperationCount]);
So calling on the main queue does block the UI in my hands. I tested both on iPhone 4S and 5 to see if it was phone dependent but I get the same result on both. Also, having your own operation queue allow you to call cancelAllOperations on the queue if you want to cancel all the ongoing import or data processing. I dont know if calling cancelAllOperations on the main queue would be such a good idea. |
|
21 Feb 2013, 20:45
Marcus S. Zarra (239 posts) |
I explored this a bit further based on this conversation and my assumption was incorrect. It does seem that I will update the same code in the projects to account for that clarification. |
| You must be logged in to comment |

