NSPredicate *predicate3 = [NSPredicate predicateWithFormat:@"ANY %K.%K.%K CONTAINS[c] %@",@"Assets",@"TFloorAssets",@"AssetNo",strSearch];
NSArray *filteredPendingList = [NSMutableArray arrayWithArray:[arrOfAllAssetsCategory filteredArrayUsingPredicate:predicate3]];
我使用上述类型的代码进行多级搜索?
答案 0 :(得分:2)
[NSPredicate predicateWithFormat:@"ANY Assets.@unionOfArrays.TFloorAssets.AssetNo contains[c] %@", strSearch]
或subquery:
[[NSPredicate predicateWithFormat:@"SUBQUERY(Assets, $asset, ANY $asset.TFloorAssets.AssetNo contains[c] %@).@count > 0", strSearch]
或两个子查询:
[NSPredicate predicateWithFormat:@"SUBQUERY(Assets, $asset, SUBQUERY($asset.TFloorAssets, $tFloorAsset, $tFloorAsset.AssetNo contains[c] %@).@count > 0).@count > 0", strSearch]
答案 1 :(得分:-1)
使用“复合谓词”,如下所示
NSPredicate *predicate = [NSCompoundPredicate orPredicateWithSubpredicates:
@[predicateEventsByAsset, predicateEventsByFloorAsset ,predicateEventsByAssetNo]];
self.filteredEventsArray = [self.eventsArray filteredArrayUsingPredicate:predicate];