【发布时间】:2019-11-15 07:23:04
【问题描述】:
我有一个字典数组,我正在尝试根据需要过滤掉“displayName”与 SearchText 相等或匹配但结果获取字典的所有值的数据,请让我知道我错在哪里。
enter image description here 我得到的数据在图像中是这样的
dic 就像static var singleDetails = [[NSDictionary]]()
这是我要过滤的代码
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String)
{
let results = variables.sinDetails.filter() { ($0[0]["displayName"] as? String) != searchText }
}
【问题讨论】:
-
不要在双精度数组中使用字典(尤其是无类型字典)之类的东西。 Swift 不是 Javascript。使用结构和类。
标签: ios swift filtering nsdictionary