nscompoundpredicate

NSCompoundPredicate

时光总嘲笑我的痴心妄想 提交于 2019-12-23 09:43:12
问题 I'm trying to filter a UITableView's data using a UISearchDisplayController and NSCompoundPredicate . I have a custom cell with 3 UILabels that I want to all be filtered within the search, hence the 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

Create complicated NSCompoundPredicate in swift 3

烈酒焚心 提交于 2019-12-02 04:42:45
问题 I want to create a complicated NSCompoundPredicate in swift 3, however, I don't know how to do this. Suppose I have 5 predicates (p1,p2,p3,p4,p5). I want to implement below conditions: compound1 = (p1 AND p2 AND p3) // NSCompoundPredicate(type: .and, //subpredicates: predicates) compound2 = (p4 AND p5) // NSCompoundPredicate(type: .and, //subpredicates: predicates) compound3 = (compound1 OR compound2) // problem is here fetchRequest.predicate = compound3 NSCompoundPredicate as it's second

Create complicated NSCompoundPredicate in swift 3

╄→尐↘猪︶ㄣ 提交于 2019-12-02 00:39:58
I want to create a complicated NSCompoundPredicate in swift 3, however, I don't know how to do this. Suppose I have 5 predicates (p1,p2,p3,p4,p5). I want to implement below conditions: compound1 = (p1 AND p2 AND p3) // NSCompoundPredicate(type: .and, //subpredicates: predicates) compound2 = (p4 AND p5) // NSCompoundPredicate(type: .and, //subpredicates: predicates) compound3 = (compound1 OR compound2) // problem is here fetchRequest.predicate = compound3 NSCompoundPredicate as it's second argument gets array of NSPredicates that it doesn't desire. What is the best solution? NSCompoundPredicate