Ios 将标题与UISearchController中的图像名称匹配

Ios 将标题与UISearchController中的图像名称匹配,ios,swift,uitableview,dictionary,uisearchbar,Ios,Swift,Uitableview,Dictionary,Uisearchbar,我有一个tableviewController,其中有一个搜索栏。当我在搜索框中键入自助餐厅名称时,会显示错误的图像和找到的名称 这是我的变量:我应该用另一种语法格式声明带有标题和图像的字典数组吗? @IBOutlet weak var RetailTableView: UITableView! //our TableView var resultSearch = UISearchController() //our UISearchbar var menuI

我有一个tableviewController,其中有一个搜索栏。当我在搜索框中键入自助餐厅名称时,会显示错误的图像和找到的名称

这是我的变量:我应该用另一种语法格式声明带有标题和图像的字典数组吗?

@IBOutlet weak var RetailTableView: UITableView!  //our TableView
        var resultSearch = UISearchController() //our UISearchbar

        var menuItems = [["20/20 Cafe" : "20_20Cafe.jpg"],
                        ["Au Bon Pain": "AuBonPain.jpg"]]

        var menuItemsFiltered = [(String)]()
这是我的TableViewFunc:

internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {  
        let cell = tableView.dequeueReusableCellWithIdentifier("RetailCell", forIndexPath: indexPath) as! ResidentialTableViewCell

        let entry = menuItems[indexPath.row]
        let image = UIImage(named: RetailImagesArray[indexPath.row])

                if self.resultSearch.active
                {
                    cell.RetailLabel.text = menuItemsFiltered[indexPath.row]
                }
                else
                {
                    cell.RetailImage.image = image
                    cell.RetailLabel.text = entry.keys //Not Working
                }
我的搜索功能也不起作用

 func updateSearchResultsForSearchController(searchController: UISearchController) {

        self.FilteredArray.removeAll(keepCapacity: false)
        let searchText = searchController.searchBar.text!.lowercaseString
        FilteredArray = RetailPlacesArray.filter({$0.lowercaseString.rangeOfString(searchText) != nil})

        RetailTableView.reloadData()
    }

请帮助,我做错了什么?

rangeOfString
如果找不到字符串,则不会返回
nil
,而是返回一个
NSRange
,位置为
NSNotFound