#import "ViewController.h"
#import "GZGroup.h"
@interface ViewController ()<UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property(nonatomic,strong)NSArray *groups;
@end
@implementation ViewController
#pragma mark - 懒加载数据
-(NSArray *)groups{
if(_groups == nil)
{
NSString *path = [[NSBundle mainBundle]pathForResource:@"sticker.plist" ofType:nil];
NSArray *arrayDict = [[NSArray alloc] initWithContentsOfFile:path];
NSMutableArray *arrayModel = [NSMutableArray array];
for(NSDictionary *dict in arrayDict){
GZGroup *model = [GZGroup groupWithDict:dict];
[arrayModel addObject:model];
}
_groups = arrayModel;
}
return _groups;
}
#pragma mark -数据源方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.groups.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
GZGroup *group = self.groups[section];
return _groups.;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
GZGroup *group = self.groups[indexPath.section];
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.text = group;
return cell;
}
-(NSString *)tableView:(UITableView*)tableView tetleForHeaderInsection:(NSInteger)section{
GZGroup *group = self.groups[section];
return group.name;
}
-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{
GZGroup *group = self.groups[section];
return group.description;
}
@end