If you have an object with a property that has a fixed setter, which one works best?
1
-(id)init {
if((self = [super init])) {
self->_retainingProperty = [[NSObject alloc] init];
}
return self;
}
2
-(id)init {
if((self = [super init])) {
self.retainingProperty = [[NSObject alloc] init];
[self.retainingProperty release];
}
return self;
}
3
-(id)init {
if((self = [super init])) {
NSObject *obj = [[NSObject alloc] init];
self.retainingProperty = obj;
[obj release];
}
return self;
}
All will be associated with the release of dealloc
Perhaps there is another way that I skipped.
source
share