2016-09-28 4 views
0

Ich habe Schwierigkeiten beim Schreiben von Code, einen Fehler im Protokoll, verwende ich Xcode 7.3.1 enter image description hereType'ViewController‘entspricht nicht Protokoll‚UITableViewDataSource‘

//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 
} 
+0

Sie müssen sein, um die gesamte Fehlermeldung zu sehen; Es sollte Ihnen sagen, welche Methoden Sie nicht implementiert haben, um diesem Protokoll zu entsprechen. – Kilazur

Antwort

0

Sie müssen die Funktion implementieren :

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

Dieser ist optional. –

2

Es sieht so aus, als ob Sie tableView(tableView: UITableView, cellForRowAtIndextPath indexPath: NSIndexPath) -> UITableViewCell falsch geschrieben haben.

Es sollte tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

+0

Er hat Recht. Nimm den T nach dem Index heraus –

Verwandte Themen