Я пытаюсь создать таблицу в качестве основного экрана моего приложения, и у меня возникают некоторые проблемы. Я правильно настроил main.storyboard, но есть функция override, которая у меня есть, что «не переопределяет суперкласс». Ошибка находится в строке поддержки переопределения nuberOfRowsInSection. Вот мой код:Настройка контроллера таблицы в Swift?
import UIKit
class ViewController: UITableViewController {
var candies = [Candy]()
@IBOutlet weak var editButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup
// after loading the view.
self.candies = [Candy(name: "Jolly Rancher"),Candy(name: "Snickers"),Candy(name: "Twix"),Candy(name: "Butterfinger"),Candy(name: "Milky Way")]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableView: UITableView, nuberOfRowsInSection section: Int) -> Int {
return self.candies.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
var candy : Candy
candy = candies [indexPath.row]
cell.textLabel?.text = candy.name
}
@IBAction func editButtonPressed(sender: UIButton) {
editButton.setTitle("Save", forState: UIControlState.Normal)
}
}
Я поймал орфографическую ошибку, но после того, как я установил, что ошибка переместилась в закрывающуюся фигурную скобку после cell.textLabel? .text = candy.name –
Какая ошибка? – Christian
Отсутствует возврат в ожидаемую функцию UITableViewCell –