Why DON’T we use the property in initializer methods and to Use the instance variable?
init {
self = [super init];
if (self) {
self.someString = [[[NSString alloc] initWithFormat:@"%@ %@",@”Mike”, @”Jones”] autorelease];
}
return self;
}
vs:
init {
self = [super init];
if (self) {
_someString = [[[NSString alloc] initWithFormat:@"%@ %@",@”Mike”, @”Jones”] autorelease];
}
return self;
}
The correct way is to do
without the
autorelease. I assume your property to beretainor (better)copy.You don’t want to call methods in init and dealloc, as they can easily have side effects, either here (now or later) or in a subclass.