Zog
Zog

Reputation: 1143

ViewController does not conform to protocol 'UISearchResultsUpdating'

The error I am receiving is that the Type 'LocationSearchTable' does not conform to protocol 'UISearchResultsUpdating'. Most of the answers to this question are to add this to the code:

func updateSearchResultsForSearchController(searchController: UISearchController) {

}

However I already had this in my code before these answers and the error is still occurring.

This is my code:

import UIKit
class LocationSearchTable : UITableViewController { }

extension LocationSearchTable : UISearchResultsUpdating {
    func updateSearchResultsForSearchController(searchController: UISearchController) {
    }
}

And the error is:

Error

Upvotes: 1

Views: 1385

Answers (1)

Zog
Zog

Reputation: 1143

The syntax needed to be update to Swift 3 and Xcode did not inform me of this.

I discovered this by command clicking on the protocol and then adding all required functions. This is a good method because it contains all the required functions in the latest syntax's.

Swift 3:

func updateSearchResults(for searchController: UISearchController) {

// code here

}

Upvotes: 6

Related Questions