Q:Value of type '[String]' has no member 'filtered'
<p>In my Code when I <code>implementation</code> my <code>func</code> :<code>filterContentForSearchText(searchText:String, scope:String)</code></p>
<p>error comes:</p>
<pre><code>let resultPredicate:NSPredicate = NSPredicate.init(format: &quot;name contains[c] \(searchText)&quot;, searchText)
resultDataSource = dataSource?.filtered(using: resultPredicate) as NSArray?  // the red error:Value of type '[String]' has no member 'filtered'
</code></pre>
<p>I post my code below:</p>
<pre><code>import UIKit

class StoreListViewController: UIViewController, UISearchBarDelegate,UISearchDisplayDelegate,UITableViewDelegate,UITableViewDataSource {

var dataSource:[String]? = nil
var resultDataSource:NSArray? = nil

override func viewDidLoad() {
    super.viewDidLoad()
    
    initData()
    initUI()
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

// MARK: - init
func initData(){

    self.searchDisplayController?.searchResultsDelegate = self
    self.searchDisplayController?.searchResultsDataSource = self
    self.searchDisplayController?.delegate = self
    
    dataSource = [&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;a&quot; ]
}
func initUI() -&gt; Void {
    
    
}


// MARK: - tableView delegate

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
    
    if tableView == self.searchDisplayController?.searchResultsTableView {
        
        return (dataSource?.count)!
    }else {
    
        return (resultDataSource?.count)!
    }
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {
    return 50
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
    
    let cell_id = &quot;StoreListTabCell&quot;
    
    var cell:StoreListTabCell = tableView.dequeueReusableCell(withIdentifier: cell_id) as! StoreListTabCell
    

    cell.title_label.text = dataSource?[indexPath.row]
    
    return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    
    tableView.deselectRow(at: indexPath, animated: true)
}

// MARK: - filter delegate
func filterContentForSearchText(searchText:String, scope:String) -&gt; Void {
    
//        NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@&quot;name contains[c] %@&quot;, searchText];
//        filteredist = [OldList filteredArrayUsingPredicate:resultPredicate];
    let resultPredicate:NSPredicate = NSPredicate.init(format: &quot;name contains[c] \(searchText)&quot;, searchText)
    resultDataSource = dataSource?.filtered(using: resultPredicate) as NSArray?  // there is the error!!!
}

func searchDisplayController(_ controller: UISearchDisplayController, shouldReloadTableForSearch searchString: String?) -&gt; Bool {
    
    //let scope_str = searchDisplayController?.searchBar.scopeButtonTitles.objectAtIndex(self.searchDisplayController.searchBar.selectedScopeButtonIndex)
    //[self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
    
    var scopeTitles:Array = (searchDisplayController?.searchBar.scopeButtonTitles)!
    
    let selected_index = searchDisplayController?.searchBar.selectedScopeButtonIndex
    
    let scope_str = scopeTitles[selected_index!]
    
    
    filterContentForSearchText(searchText: searchString!, scope:scope_str)
    
    return true
}

}
</code></pre>
<p>And in my storyboard :</p>