Я написал это в Xcode 6 (Swift), но он говорит: «Тип« FirstViewController »не соответствует протоколу« UITableViewDataSource »и не позволяет мне создавать программу. Пожалуйста помоги?FirstViewController не соответствует протоколу
import UIKit
class FirstViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//UIViewTableDataSource
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int{
return taskMGR.tasks.count
}
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
}
}
Вам не хватает 'override' перед этими двумя методами DataSource ... –
также: Вместо того, чтобы в соответствии с' 'UIViewController', UITableViewDelegate' & 'UITableViewDataSource', вы можете также сделать класс подклассом' UITableViewController' ... –
установить источник данных и делегировать его программно в viewDidLoad –