我正在尝试创建一个父-子核心数据关系。TableViewA包含汽车制造商,TableViewB包含所选制造商制造的汽车。--我想过滤汽车,以便它们只出现在其制造商表视图中。工作得相当好,但是当我在一个制造商表视图中添加一辆汽车时,它正确地显示在添加它的制造商表视图中的制造商表视图中,但在所有其他制造商表视图中,单元格只显示它们在其他制造商表视图中添加的汽车数量的默认标签("cell")。这是我的tableView:cellForRowAtIndexPath: TableViewB方法
- (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;
}请解释如何正确过滤核心数据。
发布于 2012-07-24 02:59:53
在选择制造商时,您需要修改分配给获取的结果控制器的谓词。
https://stackoverflow.com/questions/11623441
复制相似问题