Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 核心数据父子UITableView关系_Iphone_Objective C_Ios_Cocoa Touch_Core Data - Fatal编程技术网

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
是针对汽车的。我想访问我的制造商-家长关系。我也犯了同样的错误。