有時(shí)候可以直接使用plist來(lái)作為數(shù)據(jù)源,避免了一大段的文字信息在項(xiàng)目中
@property (strong,nonatomic)NSArray *themeData;//定義一個(gè)屬性
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;
根據(jù)plist里面的是array就用Array接受,是dictionary就用dictionary接收,更具實(shí)際情況而定
實(shí)例截圖
我的主頁(yè)
沙漠騎士