import UIKit
class exploreViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var searchBar: UISearchBar!
@IBOutle
From your code, I believe you are using Swift3. Then, the following are delegate and datasource methods for UITableView in Swift3
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
// Configure the cell...
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
As you can see, your numberOfSections function's syntax is wrong.That is the reason.
This is actually due to access level resolution. When we don't specify the "public" ourselves, the compiler resolves it as to be some privately implemented function and even warns that it nearly matches a public function. If one ignores this then it neglects this function and rather calls the default implementation. Hope this helps someone.
func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 }