-(void)requestChannels{
//获取plist文件路径
NSString*path = [[NSBundlemainBundle]pathForResource:@"channels"ofType:@"plist"];
NSArray*arr = [[NSArrayalloc]initWithContentsOfFile:path];
NSMutableArray*mArr = [NSMutableArrayarray];
//字典转模型
for(NSDictionary*dicinarr) {
Channel*channel = [Channelnew];
[channelsetValuesForKeysWithDictionary:dic];
[mArraddObject:channel];
}
if(_channels==nil) {
_channels= [NSArray array];
}
self.channels= mArr;
//刷新collectionview
[self.newsContentCollectionViewreloadData];
}
channels是保存模型的数组,这样plist中的数组就转成模型数组保存到channels中了.