- 静态的DataSource - 使用Plist来设置静态资源。
NSString *shopListPath = [[NSBundle mainBundle]pathForResource:@"shop" ofType:@"plist"];
self.shops = [[NSArray alloc]initWithContentsOfFile:shopListPath];
#pragma mark - TableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *sectionArray = self.shops[section];
return sectionArray?sectionArray.count:0;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.shops?self.shops.count:0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
NSArray *sectionArray = self.shops[indexPath.section];
NSDictionary *shopDict = sectionArray[indexPath.row];
cell.textLabel.text = shopDict[@"title"];
cell.detailTextLabel.text = shopDict[@"content"];
return cell;
}