Protocols not been implemented...? Help!

I have being doing the exercises, and did the worksheet (module3 lesson 5) on Protocols & Delegates, but I got stuck!!! Please help. Xcode tells me that ViewController is not conforming to the protocol.
(I thought I did…)

Here is what my worksheet looks like… What am I missing / doing wrong? HELP PLEASE

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet weak var myTableView: UITableView!

let dataArray = ["bird","dog","cat","turtle","bear"]

override func viewDidLoad() {
    super.viewDidLoad()
    
    myTableView.delegate = self
    myTableView.dataSource = self
    
    // MARK: UITableView Protocol Method IMPLEMENTATION
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return dataArray.count
        
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
    //Get the data for this row
    let rowData = dataArray[indexPath.row]
    
    //Get a cell to display
    let cell = tableView.dequeueReusableCell(withIdentifier: "BasicCell", for: indexPath)
        
   cell.textLabel?.text = rowData
        
    //Return the cell
    return cell
    }
    
}

}

You are missing a closing brace for your viewDidLoad() function so the compiler can’t see the two tableView protocol methods because they are technically inside viewDidLoad().

1 Like

Thanks roosterboy!!!

Roosterboy is right there is no closing bracket below the mytableview.datasource to close off viewdidload

Great, thank you fuerte.francis!