- (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];
}
質問する
59 次
1 に答える
2
いいえ、でもこのように書いてください
- (void)viewDidLoad
{
self.deleteButton = [[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(deleteModelTapped:)] autorelease];
self.deleteButton.image = [UIImage imageNamed:[Configuration getDeleteIconName]];
}
setPropertyexpandはこのようになります
- (void)setProperty:(XXX*)p
{
if ( property != p )
{
[property release];
property = [p retain];
}
}
「リーク」は「[UIImageimageNamed:]」を使用する可能性があります。:)
于 2012-04-18T15:40:41.843 に答える