Is it okay to lazy initialization/load all objects?
I find myself lazy initialization all my functions now. It just feels more
natural and it allows me to to stop writing setup functions. Is this bad
by design? What are the pitfalls?
@property (nonatomic, strong) NSMutableArray *array1;
-(NSMutableArray *)array1{
if (!_array1){
_array1 = [[NSMutableArray alloc] init];
}
return _array1;
}
I then find myself doing things like:
-(NSMutableArray *)array1{
if (!_array1){
_array1 = [[NSMutableArray alloc] init];
// read a file
// [_array addObject:newObject];
}
return _array1;
}
No comments:
Post a Comment