过滤的数组使用两个谓词

时间:2012-08-02 23:00:22

标签: iphone ios nsarray nsdictionary nspredicate

我想知道是否有办法使用两个filteredArrayUsingPredicates来优化数组,目前我正在使用数组中的一个值来改进它,但还有其他几个值...我想知道如何去做所以我可以通过两个varaibales来改进。

目前我在做这个

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"ISCHARGER",@"T"]; // I have another 
NSArray *filteredArray = [parsedDataArrayOfDictionaries filteredArrayUsingPredicate:predicate];

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:2)

您可以执行以下操作:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"userID == %d AND messageID == %d", currentUser, currentMessage];  

希望这有帮助,

汤姆