我将变量设置为IBOutlet。 并使用@property(retain)
@synthesize
在我的.h和.m文件中。 像这样:当我释放对象时,viewDidUnload和dealloc函数之间的区别
@interface testViewController {
NSArray *keys;
}
@property (nonatomic, retain) NSArray *keys;
@end
@implementation SectionViewController
@synthesize keys;
在很多书,他们设置对象为nil在viewDidUnload
方法和使用的排放方法来释放对象dealloc
方法。 像这样:
- (void)viewDidUnload {
self.keys = nil;
}
- (void)dealloc {
[super dealloc];
[keys release];
}
据我所知,如果我使用self.keys =零,结果是相同[keys release]
在dealloc
方法;对象键将release
,和“无”将不被保留。
为什么有些书每次都使用这种形式?
感谢
相关知识键值观察,谢谢! – Nianliang 2012-06-16 15:32:35