【问题标题】:filtered Array Using two Predicates使用两个谓词过滤数组
【发布时间】:2012-08-02 23:00:21
【问题描述】:

我想知道是否有一种方法可以使用两个filteredArrayUsingPredicates 来优化数组,目前我正在使用数组中的一个值来优化它,但是还有其他几个值......我想知道怎么做所以我可以通过两个变量来改进。

目前我正在这样做

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

任何帮助将不胜感激

【问题讨论】:

  • 你的意思是你想要一些复合谓词,比如NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(lastName like[cd] %@) AND (birthday > %@)", lastNameSearchString, birthdaySearchDate];? (在谓词编程指南中)
  • 是的,这就是我的意思......我完全应该检查文件,但我什至没有想到......对此感到抱歉。

标签: iphone ios nsarray nsdictionary nspredicate


【解决方案1】:

您只需执行以下操作:

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

希望这会有所帮助,

汤姆

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-12
    相关资源
    最近更新 更多