0
通じアイバーズの割り当て:のiOS - このインスタンス変数を考慮する性質
UILabel *label;
、以下の特性:
@property (nonatomic,retain) UILabel *label;
し、次のsynthesize:
@synthesize label;
が割り当て以下これらをです正しい(正しいメモリ管理に関して):
// 1
UILabel *tmpLabel = [[UILabel alloc] initWithFrame:CGSizeZero];
self.label = tmpLabel;
[tmpLabel release];
// 2
self.label = [[[UILabel alloc] initWithFrame:CGSizeZero] autorelease];
// 3 - This one looks shady but I haven't gotten any leaks (I suppose this will
// not use the created setter)
label = [[UILabel alloc] initWithFrame:CGSizeZero];
- (void)viewDidUnload {
self.label = nil;
[super viewDidUnload];
}
- (void)dealloc {
[label release];
[super dealloc];
}