Is this property assignment for iOS correct?
I've seen that you should assign a property this way:
- (void)viewDidLoad {
NSDateFormatter *tempFormatter = [[NSDateFormatter alloc] init];
self.dateFormatter = tempFormatter;
[tempFormatter release];
}
...
- (void)dealloc {
[dateFomatter release];
[super relase];
}
Where dateFormatter is defined like开发者_如何学Go this
// Header
@property (nonatomic, retain) NSDateFormatter *dateFormatter;
// Implementation
@synthesize dateFomatter;
This way I avoid a double assignment.
Yes, this is ok. It uses the retain
from the synthesized setter.
精彩评论