【发布时间】:2012-07-06 15:54:21
【问题描述】:
我正在使用核心数据来获取实体。我只希望这些结果显示在我的表格视图的第二部分中,而其他内容显示在另一部分中......我的应用程序没有崩溃,但获取的数据没有显示在表格视图中......我也很确定我正在正确获取数据。
这是一些代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
if (indexPath.section==0){
switch (indexPath.row) {
case 0:
cell.textLabel.text = _team.teamName;
break;
case 1:
cell.textLabel.text = _team.headCoach;
break;
default:
break;
}
}
if (indexPath.section ==1) {
Player *p = [_fetchedResultsController objectAtIndexPath: indexPath];
cell.textLabel.text = p.firstName;
cell.detailTextLabel.text = p.team.teamName;
}
return cell;
}
【问题讨论】:
-
FRC 的 if/then 位于第一部分的 if/then 内。
-
好的,我编辑了它,但现在我再次遇到同样的错误 index 1 越界 [0 .. 0]'
-
在下面查看我的编辑。问题在于将 indexPath 与 FRC 的 objectAtIndexPath 方法一起使用
-
非常感谢。非常感谢您抽出时间来帮助我...一切顺利。
标签: core-data nsfetchedresultscontroller nsindexpath