1.创建一个plist
2.填写为ImageList.plist
3.填入数据
4.完成
加载代码:
@interface UYViewController ()//图片信息的数组@property(nonatomic,strong) NSArray *imageList;@end@implementation UYViewController-(NSArray *)imageList{ if (_imageList==nil) { NSString *path=[[NSBundle mainBundle] pathForResource:@"ImageList" ofType:@"plist"]; //在OC中,通常需要完整的路径 _imageList=[NSArray arrayWithContentsOfFile:path]; } return _imageList;}@end
另:获取plist路径也可以这么写:
NSString *path = [[NSBundle mainBundle] pathForResource:@"app.plist" ofType:nil];
获取plist里的值:
//index 改为相应的行数,如1self.imageList[self.index][@"desc"];
或者:
for (int index=0; index