- (NSArray *)htmls
{
if (_htmls == nil) {
// JSON文件的路径
NSString *path = [[NSBundle mainBundle] pathForResource:@"help.json" ofType:nil];
// 加载JSON文件
NSData *data = [NSData dataWithContentsOfFile:path];
// 将JSON数据转为NSArray或者NSDictionary
NSArray *dictArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
// 将字典转成模型
NSMutableArray *htmlArray = [NSMutableArray array];
for (NSDictionary *dict in dictArray) {
MJHtml *html = [MJHtml htmlWithDict:dict];
[htmlArray addObject:html];
}
_htmls = htmlArray;
}
return _htmls;
}