读取文件
//0.1获取bundle
NSBundle *mainBundle=[NSBundle mainBundle];
//0.2获取路径
NSString *path=[mainBundle pathForResource:@"images.plist" ofType:nil];
//0.3初始化数组
NSArray *tempArr=[NSArray arrayWithContentsOfFile:path];
NSMutableArray *mutArr=[NSMutableArray array];
for (NSDictionary *dic in tempArr) {
ImageModel *newImageMod=[[ImageModel alloc]initWithDic:dic];
[mutArr addObject:newImageMod];
}
ImageModel.h
#import <Foundation/Foundation.h>
@interface ImageModel : NSObject
@property (strong,nonatomic)NSString *desc;
@property (strong,nonatomic)NSString *icon;
- (instancetype)initWithDic:(NSDictionary *)dic;
-
@end
ImageModel.m
#import "ImageModel.h"
@implementation ImageModel
- (instancetype)initWithDic:(NSDictionary *)dic{
if (self=[super init]) {
self.desc=dic[@"desc"];
self.icon=dic[@"icon"];
}
return self;
}
@end