ios - 多级复杂对象数组 进行模糊查询
PHPz
PHPz 2017-04-18 09:43:37
0
2
627
{
  "code": "1",
  "msg": "成功",
  "data": {
    "members":[
      {
        "user_uuid": "u111",
        "avatar_url": "1.png",
        "nickname": "1132",
        "group_grade": "3"   
      },
      {
        "user_uuid": "u111",
        "avatar_url": "1.png",
        "nickname": "fdsa",
        "group_grade": "2"
      },
      {
        "user_uuid": "u111",
        "avatar_url": "1.png",
        "nickname": "vcxz",
        "group_grade": "1"
      },
      {
        "user_uuid": "u111",
        "avatar_url": "1.png",
        "nickname": "fdsatgerwvcx",
        "group_grade": "1"
      },
      {
        "user_uuid": "u111",
        "avatar_url": "1.png",
        "nickname": "vcxztewq",
        "group_grade": "1"
      },
      {
        "user_uuid": "u111",
        "avatar_url": "1.png",
        "nickname": "vxcfewq",
        "group_grade": "1"
      }
      ],
  }
}

JSON格式如上,转换为了model,我现在要对这个数组里的model的nickname进行模糊查询,除了用数据库SQL查询,没有没什么直接在内存里进行的方法吗?

PHPz
PHPz

学习是最好的投资!

reply all(2)
大家讲道理

NSPredicate

左手右手慢动作

Thank you for your invitation. We need to perform a fuzzy search for the nickname in the Model. Since we need to obtain the address of the Model object to facilitate calling other attributes under the Model object, it is more troublesome to use NSPredicate to implement it. Generally, the results are returned after querying through SQL. However, There are also other methods for your reference:

for (Model *model in modelArray) {
        if ([model.name containsString:@"1"]) {
            NSLog(@"%@",model);
        }
        
    }

Here I suggest you help others more, so that more people will help you when you encounter difficulties.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template