【问题标题】:How to add a conjuction to an NSPredicate如何向 NSPredicate 添加连接
【发布时间】:2009-08-03 13:24:20
【问题描述】:

如何使用NSPredicate 匹配多个条件?

我有一个问题Select * from Entity where name = "Sony" and type ="cd";
我怎样才能在NSPredicate 中给这个and

【问题讨论】:

    标签: cocoa-touch cocoa core-data nspredicate


    【解决方案1】:

    This 来自 Apple 开发者网站,并提供了如何正确使用 NSPredicate 的示例

    【讨论】:

      【解决方案2】:

      如果您在 NSPredicate 中使用 AND 或 OR 条件,这是我的示例:

      NSPredicate *predicate =[NSPredicate predicateWithFormat:@"artist  contains[cd] %@ 
      OR album  contains[cd] %@ OR title  contains[cd] %@", 
      self.searchBar.text, self.searchBar.text, self.searchBar.text];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-27
        • 2021-11-11
        • 1970-01-01
        • 2023-03-15
        • 1970-01-01
        相关资源
        最近更新 更多