+ (NSArray *)loadDataFromPlistWithName:(NSString *)plistName{
NSString *path = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
NSArray *array = [NSArray arrayWithContentsOfFile:path];
NSMutableArray *dataArray = [NSMutableArray array];
for (int i = 0; i < array.count; i++) {
NSDictionary *dic = [array objectAtIndex:i];
//读取分组名
NSString *groupName = [dic objectForKey:@"groupName"];
//读取这一组的好友
NSArray *friendsArray = [dic objectForKey:@"friends"];
//封装每一个好友为PersonModel类型
NSMutableArray *personArray = [NSMutableArray array];
for (NSDictionary *personDic in friendsArray) {
PersonModel *person = [[PersonModel alloc] initWithName:[personDic objectForKey:@"name"] iconName:[personDic objectForKey:@"icon"] introduction:[personDic objectForKey:@"intro"]];
[personArray addObject:person];
}
NSDictionary *friendDic = @{@"friends":personArray, @"groupName":groupName};
[dataArray addObject:friendDic];
}
return dataArray;
}
+ (NSArray *)loadEmotionDataFromPlistWithName:(NSString *)plistName{
NSString *path = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
NSArray *rootArray = [NSArray arrayWithContentsOfFile:path];
NSMutableArray *dataArray = [NSMutableArray array];
for (int i = 0; i < rootArray.count; i++) {
NSDictionary *dic = [rootArray objectAtIndex:i];
NSString *chs = [dic objectForKey:@"chs"];
NSString *png = [dic objectForKey:@"png"];
EmotionModel *emotion = [[EmotionModel alloc] initWithName:chs emotionImage:png];
[dataArray addObject:emotion];
}
return dataArray;
}