UITableView's
とを使用してデータをフィルタリングしようとしていUISearchDisplayController
ますNSCompoundPredicate
。UILabels
検索内ですべてフィルタリングしたい3つのカスタムセルがあるため、 NSCompoundPredicate
。
// Filter the array using NSPredicate(s)
NSPredicate *predicateName = [NSPredicate predicateWithFormat:@"SELF.productName contains[c] %@", searchText];
NSPredicate *predicateManufacturer = [NSPredicate predicateWithFormat:@"SELF.productManufacturer contains[c] %@", searchText];
NSPredicate *predicateNumber = [NSPredicate predicateWithFormat:@"SELF.numberOfDocuments contains[c] %@",searchText];
// Add the predicates to the NSArray
NSArray *subPredicates = [[NSArray alloc] initWithObjects:predicateName, predicateManufacturer, predicateNumber, nil];
NSCompoundPredicate *compoundPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:subPredicates];
ただし、これを行うと、コンパイラは次のように警告します。
タイプ「NSPredicate*」の式で「NSCompoundPredicate*_strong」を初期化する互換性のないポインター型
私がオンラインで見たすべての例はこれとまったく同じことをしているので、私は混乱しています。NSCompoundPredicate orPredicateWithSubpredicates:
メソッドは最後の(NSArray *)
パラメーターを取りますので、私は本当に混乱しています。
どうしたの?