【发布时间】:2012-07-24 02:51:57
【问题描述】:
我正在尝试创建父子核心数据关系。 TableViewA 包含汽车制造商,TableViewB 包含所选制造商制造的汽车。 我想过滤汽车,使它们只显示在他们的制造商表格视图中。我的这个工作相当不错,但是当我在一个制造商表格视图中添加汽车时,它会正确显示在添加它的制造商表视图,但在所有其他制造商表视图中,单元格仅显示其他制造商表视图中添加的汽车数量的默认标签(“单元格”)。这是TableViewB 的tableView:cellForRowAtIndexPath: 方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Car Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Car *car = [self.fetchedResultsController objectAtIndexPath:indexPath];
if (car.manufacturer == self.currentManufacturer) {
cell.textLabel.text = car.carName;
}
return cell;
}
请解释如何在 Core Data 中正确过滤。
【问题讨论】:
标签: iphone objective-c ios cocoa-touch core-data