AL Hidayat
AL Hidayat

Reputation: 1

Type'ViewController' does not conform to protocol 'UITableViewDataSource'

I have difficulty in writing code, an error in the protocol, I use xcode 7.3.1 enter image description here

//2 Method dari protokol UITableViewDataSource->method 1.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    //Return the numberofRowsInSection.
    return namaRestoran.count
}
//Method 2.
func tableView(tableView: UITableView, cellForRowAtIndextPath indexPath: NSIndexPath) -> UITableViewCell {
    let cellIdentifier = "Cell"
    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as UITableViewCell

    //Configurasi the Cell.
    cell.textLabel?.text = namaRestoran[indexPath.row]

    return cell
}

Upvotes: 0

Views: 635

Answers (2)

Markus
Markus

Reputation: 777

It looks like you have spelled tableView(tableView: UITableView, cellForRowAtIndextPath indexPath: NSIndexPath) -> UITableViewCell incorrectly.

It should be tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

Upvotes: 2

kgkoutio
kgkoutio

Reputation: 89

You must implement the function:

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
  return 1; // Or any other number
}

Upvotes: 0

Related Questions