【发布时间】:2017-03-30 06:37:09
【问题描述】:
我已经从服务器请求了一个数组,现在我想过滤所有在一个新数组中具有"status_read": 1 的数据。我该怎么做?这是我的数据回复:
{
"status": "success",
"message": "success",
"data": [
{
"logo": "http://**.com/timepicker/images/default_o.jpg",
"title": "Title 1",
"icon": "https://**.com/admin/dashboard/dist/img/a.png",
"type": 1,
"link_detail": "",
"id_call": 12,
"status_read": 1
},
{
"logo": "http://**.com/timepicker/images/default_go.jpg",
"title": "Title 2",
"icon": "https://**.com/admin/dashboard/dist/img/b.png",
"type": 0,
"link_detail": "http://google.com",
"id_call": 0,
"status_read": 0
}
]
}
这是我的过滤器数组代码:
NSString *dictionaryKey = @"status_read";
NSInteger predicateValue = 1;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K == %i", dictionaryKey, predicateValue];
NSArray *filteredArr = [readNotif filteredArrayUsingPredicate:predicate];
generalArray = filteredArr;
[self.notifTableView reloadData];
【问题讨论】:
-
@Anbu.Karthik 我已经更新了我的代码。
标签: ios objective-c nsarray