#import "YYQQGroupModel.h"
#import "YYfriendCell.h"
#import "YYFriendsModel.h"
#import "YYHeaderView.h"
@interface YYViewController ()<YYHeaderViewDelegate>
/**
* 用来保存所有的分组数据
*/
@property(nonatomic,strong)NSArray *groupFriends;
@end
复制代码
@implementation YYViewController
#pragma mark-懒加载
//1.先拿到数据,实现懒加载
-(NSArray *)groupFriends
{
if (_groupFriends==nil) {
NSString *fullpath=[[NSBundle mainBundle]pathForResource:@"friends.plist" ofType:nil];
NSArray *arrayM=[NSArray arrayWithContentsOfFile:fullpath];
NSMutableArray *models=[NSMutableArray arrayWithCapacity:arrayM.count];
for (NSDictionary *dict in arrayM) {
YYQQGroupModel *group=[YYQQGroupModel qqGroupModelWithDict:dict];
[models addObject:group];
}
_groupFriends=[models copy];
}
return _groupFriends;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.sectionHeaderHeight = 100;
}
#pragma mark- 设置数据源
//返回多少组
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.groupFriends.count;
}
//每组返回多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// //取出对应的组模型
YYQQGroupModel *group=self.groupFriends[section];
// //返回对应组中的好友数
// return group.friends.count;
//在这里进行判断,如果该组收拢,那就返回0行,如果该组打开,就返回实际的行数
// if (group.isOpen) {
// return group.friends.count;
// }else










