如何使用Swift中的关键字过滤搜索

时间:2017-10-17 21:42:45

标签: swift

我已经知道使用类别来过滤swift表中的搜索,我希望过滤搜索,其中可能有一个特定搜索的多个关键字。

目前我的课程如下:

class Video {

    var videoName: String
    var videoTags: [String]


    init(name: String, tags: [String]) {
        self.videoName = name
        self.videoTags = tags

    }
}

据我所知,如果我使用单个字符串作为标签我可以创建搜索类别,但在这种情况下有多个标签(即“教程”,“建议”等)。

如何根据用户输入的关键字创建一个在表格中显示正确视频名称的搜索栏?

2 个答案:

答案 0 :(得分:1)

TypeError: None is not a valid string in this context

答案 1 :(得分:0)

filteredArray = userList.filter {$ 0.first_name.range(of:txtSearch.text!,options:.caseInsensitive)!=无|| $ 0.last_name.range(of:txtSearch.text!,options:.caseInsensitive)!=无|| $ 0.department.range(of:txtSearch.text!,options:.caseInsensitive)!=无