+(NSArray*)allLists {
NSMutableArray*newlists = [NSMutableArrayarray];
//1.生成plist文件的完整路徑
//[NSBundle mainBundle]獲取當(dāng)前工程的主文件夾
NSString*filePath = [[NSBundlemainBundle]pathForResource:@"news"ofType:@"plist"];
//把plist中的數(shù)據(jù)取出
NSArray*plistArray = [NSArrayarrayWithContentsOfFile:filePath];
for(NSDictionary*dicinplistArray) {
//每個字典對應(yīng)創(chuàng)建一個對象并用字典中的值給對象的屬性賦值
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];
//將新聞列表添加到數(shù)組中
[newlistsaddObject:list];
}
returnnewlists;
}