I'm just starting to read how to manage my garbage. I've been using this example code to add a cancel button on a navigation bar. But I'm pretty sure UIBarButtonItem is going to need releasing at some point. Or is the autorelease here going to handle everything at the right time?
So my question is, what's the best way to clean this up? The view can be accessed many times, so I'm thinking static class variable and thus re-using the button, but then I won't really get a chance to release it. Alternative is to make it a class instance variable, but then I'm going to be constantly alloc/release these things.
Or is this code already the best/right option?
So my question is, what's the best way to clean this up? The view can be accessed many times, so I'm thinking static class variable and thus re-using the button, but then I won't really get a chance to release it. Alternative is to make it a class instance variable, but then I'm going to be constantly alloc/release these things.
Or is this code already the best/right option?
Code:
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel)] autorelease];