【发布时间】:2017-04-16 10:28:21
【问题描述】:
我正在尝试过滤我的搜索栏,但我遇到了问题。我按照教程复制并粘贴了这段代码,但我从行中收到错误“表达式类型不明确,没有更多上下文”
return mod.profileNameLabel.lowercased().contains(text.lowercased())
我正在使用 swift 3 和 Xcode 8。我已将代码粘贴在下面:
var intialProfiles = NSMutablearray()
var profiles = NSMutablearray()
func filterTableView(ind:Int,text:String) {
switch ind {
case selectedScope.Name.rawValue:
//fix of not searching when backspacing
profiles = intialProfiles.filter(using: { (mod) -> Bool in
return mod.profileNameLabel.lowered().contains(text.lowercased())
})
self.searchTableView.reloadData()
【问题讨论】:
-
NSMutableArray在 Swift 中是可怕的。使用原生 SwiftArray.