@property (nonatomic, strong) NSArray * tgs;
-(NSArray *)tgs {
if (_tgs == nil) {
NSString* path = [[NSBundle mainBundle] pathForResource:@"tgs.plist" ofType:nil];
NSArray* dictArray = [NSArray arrayWithContentsOfFile:path];
NSMutableArray *tgArray = [NSMutableArray array];
for (NSDictionary *dict in dictArray) {
MJTg *tg = [MJTg tgWithDict:dict];
[tgArray addObject:tg];
}
_tgs = tgArray;
}
return _tgs;
}
这样写的目的是在于,如果ios内存过低,系统可能会回收相关资源。
当回收资源后,_tgs可能为nil。