我想根据多个开关/复选框过滤数组
这是我所拥有的:
一个带有 TableView 的 UIViewController
我在 NSArray 中使用 Alamofire 获取 json 请求
我用那个数组填充我的 TableView
这是我想要做的(但不知道如何到达那里):
我的例子:
我有一个我想根据这些过滤器过滤的餐馆列表:
1.
2.
PS:搜索栏根据餐厅名称正常工作。
先感谢您
您可以filter
根据您的要求使用函数,例如,如果您有响应array
并且每个对象都有type
键,那么
let filteredArray = array.filter({ $0.type == "wifi" || $0.type == "parking" || $0.type == "debitcard" || $0.type == "alcohol" || $0.type == "climatisation" || $0.type == "terrace"})
现在填充你的表格视图 filteredArray
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句