如何过滤task_status作为一个看到,被接受,被拒绝?

时间:2016-02-10 13:42:41

标签: objective-c json

这是我的json格式:

{
  "my_todo": [
    {
      "task_id": "71",
      "task_status": "Seen",
      "task_status_id": "2",
      "task_status_color": "warning",
      "task_sub": "Test",
      "task_content": "Testing",
      "task_from_id": "2",
      "task_from": "Aditi Sen",
      "task_lastdate": "2016-01-21"
    },
    {
      "task_id": "70",
      "task_status": "Accepted",
      "task_status_id": "4",
      "task_status_color": "success",
      "task_sub": "checking ",
      "task_content": "no of new task",
      "task_from_id": "2",
      "task_from": "Aditi Sen",
      "task_lastdate": "2016-01-19"
    },
    {
      "task_id": "69",
      "task_status": "Accepted",
      "task_status_id": "4",
      "task_status_color": "success",
      "task_sub": "checking ",
      "task_content": "no of new task",
      "task_from_id": "2",
      "task_from": "Aditi Sen",
      "task_lastdate": "2016-01-19"
    }
  ]
}

1 个答案:

答案 0 :(得分:0)

您可以使用NSPredicate

NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"task_status contains[cd] %@", @"seen"];
NSArray *filteredArray = [NSArray arrayWithArray:[jsonArray filteredArrayUsingPredicate:resultPredicate]];

我希望这有帮助!