Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-04-2009, 12:28 PM   #1 (permalink)
MatuX
Registered Member
 
Join Date: May 2009
Posts: 57
Default To autorelease or not to autorelease

I was reading a code example from a book when I found this:

Code:
	
[self.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc]
	initWithTitle:@"Randomize"
	style:UIBarButtonItemStylePlain
	target:self
	action:@selector(randomizePositions)] autorelease]];
If I do a refcount or retainCount for self.navigationItem.rightBarButtonItem it shows that it has 3 references!
Why? Should I care?
Why do I have to write autorelease there?
What if I don't?
When do I know I should call autorelease?

Best regards,
Matias

Last edited by MatuX; 06-04-2009 at 12:34 PM.
MatuX is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 280
22 members and 258 guests
aderrington, Alexman, AlexTheMighty, arcturus, Bertrand21, Cathy, Chilibird, Corund, evana, Falcon80, fanstarmike, Glnn, headkaze, jhaynie, kalygraphix, mac514, pereorra, shuvo1879, Slecorne, smrtital, Stan Edge, tlikyu
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,228
Threads: 39,007
Posts: 171,098
Top Poster: smasher (2,570)
Welcome to our newest member, SSL Matrix
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:45 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.