当使用谓词时,我们可以有:
filterPredicate = [NSPredicate predicateWithFormat:@"(ANY names.firstName contains[c] %@), nameToSearchFor];
使用
ANY
允许我们查找名称集合中任何对象具有
firstName
是否可以在Swift 3中对过滤器表达式执行类似操作?换句话说,类似于:
allPeople.filter { $0.(ANY)names.firstName.contains(searchString) };
(以上任何语法都是为了进行说明而编写的)。
reduce
这连接了所有的名字,然后看看我的目标字符串是否包含在其中?