저는 초급자로 지금부터 몇 달 동안 신속하게 학습을 시작합니다. 타이머 무효화 문제로 도와주세요. 나를 어리 석게 느끼게 자유롭게해라. :). 좀 지저분한 것 같아요. 다음 번에 더 잘 할 수있는 방법을 알려주고 있습니다.신속한 타이머 무효화, tableView 셀 내
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