我只是自己熟悉與CLLocationManager,發現包含以下init()方法的若干樣本的類定義:爲什麼在init方法中爲iVar定義調用autorelease?
- (id) init {
self = [super init];
if (self != nil) {
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self;
}
return self;
}
- (void)dealloc {
[self.locationManager release];
[super dealloc];
}
我不明白爲什麼伊娃將被自動釋放。這不是否意味着它在init方法結束時被釋放了嗎?
我也很疑惑,看到相同的示例代碼在dealloc方法中有iVar版本。
有什麼想法? '
嗨亞歷克斯,但你再次解除我的困惑。非常感謝 – iFloh 2010-04-30 12:35:38