I know this is probably a noob question, but how can I insert data from into a table view from another View Controller? Here is my code:
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)
}
}
}
I need to insert time into the AllList tableView, but this doesn't work, unfortunately. Here is my addData function:
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()
}
Please help:/
Here is the console message:
fatal error: unexpectedly found nil while unwrapping an Optional value 2017-09-14 22:09:29.011455+0300 Parkovka![504:47018] fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)