Reputation: 131
I'm learning Swift and following some tutorials. I keep getting an error: Type
'ViewController' does not conform with protocol 'UITableViewDataSource'
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var GetAllDataTest = NSMutableArray()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewWillAppear(_ animated: Bool) {
GetAllDataTest = FMDBDatabaseModel.getInstance().GetAllData()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TestTableViewCell") as! TestTableViewCell
//cell.editData = self
cell.tag = indexPath.row
var l = Tbl_Test()
l = GetAllDataTest.object(at: indexPath.row) as! Tbl_Test
cell.lblName.text! = l.Name
cell.lblMobileNo.text! = l.MobileNo
cell.lblEmail.text! = l.Email
return cell
}
}
Here is what I have tried so far:
Thanks
Upvotes: 0
Views: 2536
Reputation: 4141
You need to implement other methods as well. Here you are missing
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return GetAllDataTest.count
}
Upvotes: 5