0
我知道這可能是一個noob問題,但我怎樣才能從另一個視圖控制器的表視圖插入數據?這裏是我的代碼:如何將數據插入到另一個視圖控制器的tableView中?
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
var needToSegue = false
switch result {
case .cancelled:
print("Mail cancelled")
case .saved:
print("Mail saved")
case .sent:
needToSegue = true
print("Mail sent")
case .failed:
print("Mail sent failure: \(error?.localizedDescription ?? "nil")")
}
controller.dismiss(animated: true) {
if needToSegue {
self.AllListOfViolations.addData(Time: "\(self.LocationAndTimeData.getTextDate())")
self.performSegue(withIdentifier: "AllList", sender: self)
}
}
}
我需要插入時間到AllList tableView,但這不起作用,不幸的是。這裏是我的addData功能:
func addData(Time: String) {
violationType.append(Time)
// Update Table Data
tableView.beginUpdates()
tableView.insertRows(at: [IndexPath(row: violationType.count-1, section: 0)], with: .automatic)
tableView.endUpdates()
}
請幫助:/
這裏是控制檯消息:
致命錯誤:意外發現零而展開的可選值 2017年9月14日22: 09:29.011455 + 0300 Parkovka![504:47018]致命錯誤:意外發現零而展開的可選值 (LLDB)
調用FUNC在viewDidLoad中添加你所得到的控制檯錯誤讓我們能夠幫助您更好地 –
只是一個提示,定義變量時使用較低的駱駝盒防止與類型混淆。 –
感謝您的建議。編碼非常新穎。 –