I usually use code like this:
dispatch_queue_t queue = dispatch_queue_create("queue_name", NULL);
dispatch_async(queue, ^{
//Code
});
I know that accessing my Core Data store from here and then from another thread at the same time causes a crash. Would I be able to keep using that code above, with the same queue name, for accessing Core Data throughout my app? Would the app realise it to be the same queue, or does it forget the queue names?
The names that you pass to
dispatch_queue_create()have no significance to the system, i.e., you won’t get the same queue back if you pass the same name. They’re just labels for debugging.If you want to use the same queue in different areas, you need to store it in a variable that’s accessible in those scopes.