我正在尝试UITableView's使用UISearchDisplayController和过滤数据NSCompoundPredicate.我有一个3的自定义单元格UILabels,我想在搜索中过滤所有内容,因此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];
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做时,编译器警告我:
不兼容的指针类型使用"NSPredicate*"类型的表达式初始化"NSCompoundPredicate*_strong"
我在网上看到的每个例子都是完全相同的,所以我很困惑.该NSCompoundPredicate orPredicateWithSubpredicates:方法采用(NSArray *)最后一个参数,所以我真的很困惑.
怎么了?
objective-c uisearchbar uisearchdisplaycontroller nscompoundpredicate