Reputation: 655
This is slightly confusing for me because I'm reading an Objective-C book from 2009 (it's the only edition my library had) and the author constantly reminds the reader to release memory, but I get an error when I try to use this method. I read up a little about it and I found out that the release method is deprecated, but is there something I need to do instead of the release method to manage memory, or does Objective-C have garbage collection now?
For example:
NSString *s = [[NSString alloc] init];
[s release];
Upvotes: 0
Views: 80
Reputation: 188
You have ARC enabled; calls to retain
and release
are automatically inserted by the compiler. If you want to do the memory management manually, disable ARC in the target’s build settings. On OS X, there is also garbage collection but it is deprecated.
Upvotes: 2
Reputation: 1079
It is not garbage collection but Automatic Reference Counting
(ARC
) at work for you.
To follow the examples in your book, create a new project in Xcode and deselect the option to use ARC.
Upvotes: 3