вот ошибка
Thread 1: Exception: "unable to dequeue a cell with identifier carCell
- must register a nib or a class for the identifier or connect a prototype cell in a storyboard"
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return lappedTimes.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "carCell", for: indexPath)
cell.textLabel?.text = lappedTimes[indexPath.row]
return cell
}
@IBOutlet weak var timeLabel: UILabel!
@IBOutlet weak var goal: UIButton!
@IBOutlet weak var trick: UIButton!
@IBOutlet weak var fail: UIButton!
@IBOutlet weak var other: UIButton!
@IBOutlet weak var tableView: UITableView!
var lappedTimes:[String] = []
private var timer: Timer!
override func viewDidLoad() {
tableView.delegate = self
tableView.dataSource = self
super.viewDidLoad()
// Do any additional setup after loading the view.
timer = Timer.scheduledTimer(timeInterval: 1,
target: self,
selector: #selector(countSeconds(_:)),
userInfo: nil,
repeats: true)
}
@objc func countSeconds(_ sender: Timer) {
let date = Date()
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date)
let minutes = calendar.component(.minute, from: date)
let seconds = calendar.component(.second, from: date)
let hourString = String(hour)
let minutesString = String(minutes)
let secondsString = String(seconds)
DispatchQueue.main.async {
self.timeLabel.text = hourString + ":" + minutesString + ":" + secondsString
}
}
@IBAction func goal(_ sender: UIButton) {
let currentTime = "\(timeLabel.text!)"
lappedTimes.append(currentTime)
tableView.reloadData()
}
}