我試圖過濾我的搜索欄,但我遇到了問題。我也跟着教程和複製並粘貼此代碼,但我得到一個錯誤「表達的類型是沒有更多的背景下曖昧」從表達式類型不明確,沒有更多上下文 - .filter
return mod.profileNameLabel.lowercased().contains(text.lowercased())
我使用SWIFT 3和8的Xcode我貼我的代碼行下面:
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'Array'。 – vadian