【发布时间】:2018-08-02 04:44:25
【问题描述】:
我有一个 SwiftyJson 对象。
我无法过滤该数组。我已经尝试过这个解决方案https://stackoverflow.com/a/37497170/4831567。但是我的 json 格式不同,这就是为什么不工作的原因。
[
{
"name": "19860",
"header": {
"start_time": "1519270200",
"end_time": "1519299000",
"state": "lunch"
},
"alerts": "1",
"venue": {
"location": "Delhi, India",
"timezone": "+05:30"
},
"srs_category": [
0,
1
]
},
{
"name": "19861",
"header": {
"start_time": "1519270200",
"end_time": "1519299000",
"state": "Dinner"
},
"alerts": "1",
"venue": {
"location": "Mumbai, India",
"timezone": "+05:30"
},
"srs_category": [
1,
3
]
},
{
"name": "19862",
"header": {
"start_time": "1519270200",
"end_time": "1519299000",
"state": "lunch"
},
"alerts": "1",
"venue": {
"location": "Surat, India",
"timezone": "+05:30"
},
"srs_category": [
0,
2
]
}
]
我想找到 srs_category 包含 1 的对象。我知道通过循环和条件是可能的。但我想通过 NSPredicate。如果可以的话,请帮帮我。
谢谢。
【问题讨论】:
标签: ios json swift nspredicate swifty-json