So I can't seem to get this error away..
My code is:
class FirstViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tblTasks: UITableView!
//UITableViewDataSource
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int{
return taskMgr.tasks.count
}
//UITableViewDataSource
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!{
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "test")
cell.textLabel!.text = taskMgr.tasks[indexPath.row].name
cell.detailTextLabel!.text = taskMgr.tasks[indexPath.row].desc
return cell
}
}
I used both of the required functions for UITableViewDataSource so I'm not sure why I keep getting this error.
Try changing the method signatures as mentioned below. Notice ! is removed in the input params.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
}
Neither of each method's respective tableView parameters should be optionals
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With