【发布时间】:2010-04-30 09:22:19
【问题描述】:
我刚刚熟悉了 CLLocationManager,发现了几个包含以下 init 方法的示例类定义:
- (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];
}
我不明白为什么 iVar 会自动发布。这不是说在init方法结束时就被释放了吗?
看到同样的示例代码在dealloc方法中有iVar释放,我也很疑惑。
有什么想法吗? '
【问题讨论】:
标签: iphone objective-c xcode core-location cllocationmanager