I'm learning how to program on the iOS operating system using the book "Head first iPhone and iPad development" (second edition).
When I try to compile the code from the book, I get the error that the use release
keyword is not allowed in reference counting mode.
Do I have to explicitly release the memory in this case? If yes - how?
Sounds like your book predates ARC.
You can develop an application with the same code if you disable ARC in the project settings:
But... ARC has been out for a while, and iOS changes fast. If the book doesn't mention ARC, it's a probably sign that it targets a version of the iOS SDK less than 5.0, which is not necessarily the best way to learn iOS development these days.
You can roughly translate to an ARC environment by just removing [super dealloc]
, retain
, release
, and autorelease
from the code you see. But it's valuable to understand why those are there in the first place and why they're no longer necessary with ARC.
You have enabled Automatic Reference Counting (ARC)
in your project. That means that you can skip those dealloc
, release
and autorelease
commands. :-)
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