Iphone 核心数据父子UITableView关系
我正在尝试创建父子核心数据关系Iphone 核心数据父子UITableView关系,iphone,objective-c,ios,cocoa-touch,core-data,Iphone,Objective C,Ios,Cocoa Touch,Core Data,我正在尝试创建父子核心数据关系TableViewA包含汽车制造商,TableViewB包含所选制造商生产的汽车我想过滤汽车,使其仅显示在制造商表视图中。我的操作相当顺利,但当我在一个制造商表视图中添加汽车时,它会正确显示在添加汽车的制造商表视图中,但在所有其他制造商表视图中,单元格仅显示其默认标签(“单元格”),表示在其他制造商表视图中添加的汽车数量。这是我的tableView:cellForRowAtIndexPath:方法,用于tableView b: - (UITableViewCell
TableViewA
包含汽车制造商,TableViewB
包含所选制造商生产的汽车我想过滤汽车,使其仅显示在制造商表视图中。我的操作相当顺利,但当我在一个制造商表视图中添加汽车时,它会正确显示在添加汽车的制造商表视图中,但在所有其他制造商表视图中,单元格仅显示其默认标签(“单元格”),表示在其他制造商表视图中添加的汽车数量。这是我的tableView:cellForRowAtIndexPath:
方法,用于tableView b
:
- (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;
}
请解释如何正确筛选核心数据。选择制造商后,您需要修改分配给获取结果控制器的谓词。我添加了一个NSPredicate
request.predicate=[NSPredicate predicateWithFormat:@“Car.manufacturerName=%@”,CurrentManufacturerName]
但我收到一个错误:***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“实体中未找到关键路径Car.manufacturer.manufacturerName”
我尝试了一些组合的NSPredicate
。如何:[NSPredicate predicateWithFormat:@“manufacturer.manufacturerName=%@”,currentManufacturer.manufacturerName]我的fetchRequest
是针对汽车的。我想访问我的制造商-家长关系。我也犯了同样的错误。