O'Reilly logo

The Complete Idiot's Guide® To iPad and iPhone App Development by Troy Brant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Autorelease

There is one last concept you need to know to properly manage memory: autorelease. Autorelease is best illustrated and explained using an example.

An Example

Imagine you define a method that creates a new object and returns it:
126
At first glance, the code might look fine, but there is a problem. The voter object is leaked because there is no corresponding release to balance the alloc/init.
To fix this, let’s try adding a release to balance the alloc/init:
127
The code is fixed, right? Let’s count the references: when voter is initialized, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required