NS predicate在dictonary阵列内部密钥 [英] NSPredicate for inner key in array of dictonary

查看:144
本文介绍了NS predicate在dictonary阵列内部密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有百科在以下格式的数组

  [
 {
      学生:{
        ID:1        studentUserDetail:{
          名字:邦尼
          姓氏:罗比
        }
    } }, {
      学生:{
        ID:1        studentUserDetail:{
          名字:邦尼
          姓氏:凯蒂
        }
    } }, {
      学生:{
        ID:1        studentUserDetail:{
          名字:阿瑟,
          姓氏:Fone公司
        }
    } },]

在上面的数组我需要过滤包含在这里面关键student.StudentUserDetails.firstName一个serachKey(如邦尼)的所有元素。我如何使用过滤NS predicate


解决方案

  NS predicate *过滤器= NS predicate predicateWithFormat:@student.studentUserDetail .firstName包含:[CD]%@,搜索字符串];

工作完美的我。

i have an array of dictionay in the following format

    [
 {
      "student": {
        "id": "1",

        "studentUserDetail": {
          "firstName": "Bonny",
          "lastName": "Roby"  
        }
    }

 },

 {
      "student": {
        "id": "1",

        "studentUserDetail": {
          "firstName": "Bonny",
          "lastName": "Kety"  
        }
    }

 },

 {
      "student": {
        "id": "1",

        "studentUserDetail": {
          "firstName": "Arther",
          "lastName": "Fone"  
        }
    }

 },

]

In the above array i need to filter all elements containing a serachKey (eg Bonny) in the inside key student.StudentUserDetails.firstName . How can i filter using NSPredicate

解决方案

NSPredicate *filter =  [NSPredicate predicateWithFormat:@"student.studentUserDetail.firstName CONTAINS[cd] %@ ", searchString];

worked perfectly for me

这篇关于NS predicate在dictonary阵列内部密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆