
#import "ViewController.h"
#import "CarData.h"
#import "MyTableViewCell.h"
@interface ViewController ()<UITableViewDataSource>
@property(nonatomic,weak)UITableView *tableview;
@end
NSString *ID = @"car";
@implementation ViewController
{
NSArray * _carData;
}
- (void)viewDidLoad {
[super viewDidLoad];
_carData = [self loadCarData];
[self createTableview];
[self.tableview registerClass:[MyTableViewCell class] forCellReuseIdentifier:ID];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _carData.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
CarData *cardata = _carData[section];
return cardata.cars.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPat