• iOS 谓词 NSPredicate 对字典NSDictionary的筛选


    很久很久没有更新博客了,记录下一些经验吧

    • 谓词 NSPredicate 对字典NSDictionary的筛选
    • [NSPredicate predicateWithFormat:@"SELF['your_key'] = %@", key]  //SELF即为集合内某个字典对象

      对应单引号的使用一些注意:

      谓词表达式传入的参数若直接写在Format内,则需要添加单引号修饰,区别规则和匹配内容;

      若是通过占位符传入,则不需要添加单引号修饰;任何一种错误的使用单引号都会匹配失败

      备注:

      若是集合存放为自定义Model,做筛选 [NSPredicate predicateWithFormat:@"your_key = %@", key] 

      若是值为NSNumber类型,且需要转为值类型做比较,可 [NSPredicate predicateWithFormat:@"'your_key.integerValue' = %lu", key]

       关于谓词的使用,就不再赘述了,之前的博客 http://www.cnblogs.com/pruple/p/5865208.html

  • 相关阅读:
    正则表达式之re模块
    collections模块
    openpyxl模块
    hashlib模块
    random模块
    os模块
    sys模块
    nodeType
    数据类型转换
    添加删除
  • 原文地址:https://www.cnblogs.com/pruple/p/7451515.html
Copyright © 2020-2023  润新知