Following an iOS 5 tutorial on the Paul Hegarty course we see this code in an app that demonstrates use of GCD. Apparently GCD requires release because of issues to do with multithreading being somewhat unpredictable in what objects are still needed.
dispatch_async(dowloadQueue, ^{
....
// do some stuff
....
});
dispatch_release(dowloadQueue);
I have upgraded to iOS 6 and XCode 4.5 and I get an "ARC forbids explicit release ..." message
I did not try this code under iOS5 / XCode 4.2
Is this just because ARC got more clever and I no longer need release in GCD? Or have I just misunderstood?
When you target Mountain Lion and iOS 6.0, ARC will now manage dispatch queues and other GCD types for you. If you target earlier versions of OS X or iOS, you will still need to explicitly retain and release GCD types (not just for thread safety reasons, you'll leak memory otherwise), but this is handled for you when only targeting the newer OS versions.
This is why you see such a compiler error under ARC when targeting iOS 6.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With