热门搜索 :
考研考公
您的当前位置:首页正文

加载plist文件里面的内容

来源:东饰资讯网

有时候可以直接使用plist来作为数据源,避免了一大段的文字信息在项目中

@property (strong,nonatomic)NSArray *themeData;//定义一个属性

NSString *path = [[NSBundle mainBundle]pathForResource:@"settingsMnueData" ofType:@"plist"];
    NSArray *array = [NSArray arrayWithContentsOfFile:path];

    NSMutableArray *mutableArray = [NSMutableArray array];
    for (NSDictionary *dic in array) {
        YLSetingTheme *theme = [YLSetingTheme setingThemeWithDic:dic];
        [mutableArray addObject:theme];
    }
    self.themeData = mutableArray;

根据plist里面的是array就用Array接受,是dictionary就用dictionary接收,更具实际情况而定


实例截图
Top