Why call autorelease for iVar definition in init method?
- by iFloh
Hi, I just familiarise myself with the CLLocationManager and found several sample class definitions that contain the following init method:
- (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];
}
I don't understand why the iVar would be autoreleased. Does this not mean it is deallocated at the end of the init method?
I am also puzzled to see the same sample codes have the iVar release in the dealloc method.
Any thoughts?
'