I declared a property to reference a GCD queue:
@property (assign) dispatch_queue_t backgroundQueue;
In the init method of a class I create a serial queue:
backgroundQueue = dispatch_queue_create("com.company.app", DISPATCH_QUEUE_SERIAL);
ARC complains: "Assigning retained object to unsafe_unretained variable; object will be released after assignment"
Must I use __bridge_transfer?
In -dealloc I am releasing the queue:
dispatch_release(backgroundQueue);
Again, ARC complains: "ARC forbids explicit message send of 'release'"
I find this confusing because this is a C function call and thought queues are C objects for which I must take care of memory management myself! Since when does ARC handle the C-objects for me?
Best Answer
In iOS 6 you can cmd+click dispatch_queue_t and see this:
So simply use strong in the property (unless the queue is referenced elsewhere and you really want a weak reference).
Before iOS 6 you have to do memory management yourself using dispatch_retain and dispatch_release. Doing this in iOS 6 will throw a compiler error.