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