+(NSArray*)allLists {
NSMutableArray*newlists = [NSMutableArrayarray];
//1.生成plist文件的完整路径
//[NSBundle mainBundle]获取当前工程的主文件夹
NSString*filePath = [[NSBundlemainBundle]pathForResource:@"news"ofType:@"plist"];
//把plist中的数据取出
NSArray*plistArray = [NSArrayarrayWithContentsOfFile:filePath];
for(NSDictionary*dicinplistArray) {
//每个字典对应创建一个对象并用字典中的值给对象的属性赋值
NewsList*list = [[NewsListalloc]init];
//list.title = dic[@"title"];
//list.newsImage = dic[@"newsImage"];
//list.commentCount = [dic[@"commentCount"] integerValue];
//KVCKey Value Coding
//会字典把所有的key逐个取出,然后用每个key的名字和对象的属性名字进行匹配,如果key和属性名称一样,就把value取出给该属性赋值
[listsetValuesForKeysWithDictionary:dic];
//将新闻列表添加到数组中
[newlistsaddObject:list];
}
returnnewlists;
}