0

従業員を表示するテーブル リストの結果をフィルター処理しようとしています。1 つのフィルターで、(会社名に基づいて) 特定の会社に属するすべての従業員を表示する必要があります。

Core Data では、エンティティ Company はエンティティ Employee との対多関係を持っています。

_fetchRequest = [[NSFetchRequest alloc] init];
[_fetchRequest setEntity:[NSEntityDescription entityForName:@"Employee" inManagedObjectContext:_moc]];

NSPredicate *employeeNamePredicate = [NSPredicate predicateWithFormat:@"name != %@",@"Bob"];
NSPredicate *employeeCompanyNamePredicate = [NSPredicate predicateWithFormat:@"company.name == %@",companyName];

NSArray *filters = @[employeeNamePredicate, employeeCompanyNamePredicate];

NSPredicate *compoundPredicate = [NSCompoundPredicate andPredicateWithSubpredicates:filters];

[_fetchRequest setPredicate:compoundPredicate];

NSError *error = nil;
_filteredResult = [_moc executeFetchRequest:_fetchRequest error:&error];

しかし、実際には何も起こりません。@"company.name" は期待どおりに動作しないようです。私は何を間違っていますか?

4

0 に答える 0