懒加载
// 懒加载
- (NSArray *)shops
{
if (_shops == nil) {
NSString *file = [[NSBundle mainBundle]pathForResource:@"shops" ofType:@"plist"];
_shops = [NSArray arrayWithContentsOfFile:file];
}
return _shops;
懒加载字典转模型
// 懒加载字典转模型
- (NSArray *)shops
{
if (_shops == nil) {
NSArray *dictArray= [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"shops" ofType:@"plist"]];
NSMutableArray *shopArray = [NSMutableArray array];
for (NSDictionary *dict in dictArray) {
HCShop *shop = [HCShop shopWithDict:dict];
[shopArray addObject:shop];
}
_shops = shopArray;
}
return _shops;
}
网友评论