私は初心者です。タイマー無効化の問題で私を助けてください。私が愚かな気分にさせてください:)。私はちょっと混乱していることを知っています。次回はもっとうまくやる方法を教えてもらいたいと思います。テーブルビューのセル内でのスワイタイマーの無効化
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath) as! CustomCustomerCell
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let object = appDelegate.Queuelist[indexPath.row]
if let genderInital = object.gender?.characters.first {
cell.genderlabel.text = " \(genderInital)"
}
object.timerStarted()
cell.waitedTimeLabel.text = "\(object.counter)"
cell.nameLabel.text = object.name
cell.languageLabel.text = object.language
cell.reasonLabel.text = object.reasonOfVisit
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
var customerName: String?
if let indexPathForName = tableView.indexPathForSelectedRow {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let selectedCustomer = appDelegate.Queuelist[indexPathForName.row]
customerName = selectedCustomer.name
}
let alertController = UIAlertController(title: customerName, message: "message", preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "cancel", style: .cancel, handler: nil)
let editAction = UIAlertAction(title: "edit", style: .default) {action -> Void in
self.performSegue(withIdentifier: "addSegue", sender: alertController)
}
let takeCustomerAction = UIAlertAction(title: "take customer", style: .default) {
action -> Void in
if let indexpath = tableView.indexPathForSelectedRow {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let object = appDelegate.Queuelist[indexpath.row]
object.timer?.invalidate()
appDelegate.Queuelist.remove(at: indexpath.row)
appDelegate.storedQueuelist()
tableView.deleteRows(at: [indexPath], with: .fade)
}
}
alertController.addAction(takeCustomerAction)
alertController.addAction(editAction)
alertController.addAction(cancelAction)
self.present(alertController, animated: true, completion: nil)
}
あなたは何を達成しようとしているのか、どのような問題が発生しているのか、何を試したのですか? – Jelle