Autorelease vs. Release
Posted
by Sheehan Alam
on Stack Overflow
See other posts from Stack Overflow
or by Sheehan Alam
Published on 2010-05-05T20:20:20Z
Indexed on
2010/05/05
20:28 UTC
Read the original article
Hit count: 206
Given the two scenarios, which code is best practice and why?
Autorelease
loginButton = [[[UIBarButtonItem alloc] initWithTitle:@"Login"
style:UIBarButtonItemStylePlain
target:self
action:@selector(loginButtonClicked:)]
autorelease];
self.navigationItem.rightBarButtonItem = loginButton;
or
Release
loginButton = [[UIBarButtonItem alloc] initWithTitle:@"Login"
style:UIBarButtonItemStylePlain
target:self
action:@selector(loginButtonClicked:)];
self.navigationItem.rightBarButtonItem = loginButton;
[loginButton release];
© Stack Overflow or respective owner