- (void)viewDidLoad //In this scenario it only gets called once, but in other bits of code with same property initialisation it might be called more than once
{
deleteButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(deleteModelTapped:)]; //Is this leaking?
self.deleteButton.image = [UIImage imageNamed:[Configuration getDeleteIconName]];
}
@property (nonatomic, retain) IBOutlet UIBarButtonItem *deleteButton;
- (void)dealloc
{
[deleteButton release];
[super dealloc];
}
答案 0 :(得分:2)
- (void)viewDidLoad
{
self.deleteButton = [[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(deleteModelTapped:)] autorelease];
self.deleteButton.image = [UIImage imageNamed:[Configuration getDeleteIconName]];
}
setProperty展开可能就像这样
- (void)setProperty:(XXX*)p
{
if ( property != p )
{
[property release];
property = [p retain];
}
}
“泄漏”可能使用“[UIImage imageNamed:]”; :)