I am 100 percent sure that everything is connected properly yet I keep getting a SIGABRT error.
Here is the code for SelectViewController:
import UIKit
class SelectViewController: UIViewController {
var accounttype = 0
@IBAction func AdminButton(_ sender: Any) {
}
@IBAction func ParentButton(_ sender: Any) {
}
@IBAction func DriverButton(_ sender: Any) {
}
@IBAction func StudentButton(_ sender: Any) {
accounttype = 1
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
var SubmitController = segue.destination as! SubmitViewController
SubmitController.john = accounttype;
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Here is the code for SubmitViewController:
import UIKit
class SelectViewController: UIViewController {
var accountType = 0
@IBAction func AdminButton(_ sender: Any) {
}
@IBAction func ParentButton(_ sender: Any) {
}
@IBAction func DriverButton(_ sender: Any) {
}
@IBAction func StudentButton(_ sender: Any) {
accountType = 1
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destination = segue.destination as? SubmitViewController {
destination.john = accountType
print("Inside if statement")
}
}
override func viewDidLoad() {
super.viewDidLoad()
print("Out of if statement")
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Here is the console:
2018-08-28 17:17:56.529276-0700 SchoolDrive[5178:1005170] 5.4.1 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.50001000 started
2018-08-28 17:17:56.529921-0700 SchoolDrive[5178:1005170] 5.4.1 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see https://help.apple.com/xcode/mac/8.0/#/dev3ec8a1cb4)
2018-08-28 17:17:57.024884-0700 SchoolDrive[5178:1005198] TIC Read Status [1:0x0]: 1:57
2018-08-28 17:17:57.025067-0700 SchoolDrive[5178:1005198] TIC Read Status [1:0x0]: 1:57
2018-08-28 17:18:01.737912-0700 SchoolDrive[5178:1005175] TIC Read Status [2:0x0]: 1:57
2018-08-28 17:18:01.738363-0700 SchoolDrive[5178:1005175] TIC Read Status [2:0x0]: 1:57
2018-08-28 17:18:03.755460-0700 SchoolDrive[5178:1005196] TIC Read Status [3:0x0]: 1:57
2018-08-28 17:18:03.755664-0700 SchoolDrive[5178:1005196] TIC Read Status [3:0x0]: 1:57
Could not cast value of type 'SchoolDrive.SecondRegisterViewController' (0x10d8349d0) to 'SchoolDrive.SubmitViewController' (0x10d834820).
2018-08-28 17:18:04.613651-0700 SchoolDrive[5178:1004484] Could not cast value of type 'SchoolDrive.SecondRegisterViewController' (0x10d8349d0) to 'SchoolDrive.SubmitViewController' (0x10d834820).
(lldb)
I am very grateful for all help and all help is appreciated. Thank you in advance. I need all help as fast as I can get it. This will make it easier for me. Again thank you so much for all the hep and I am very grateful.
It is crashing in you case because of the force cast to fix that use if let
or guard
to prevent crashing. Modify your code in prepare(for:, sender:)
method to below.
if let destination = segue.destination as? SubmitViewController {
destination.john = accountType
}
or
guard let destination = segue.destination as? SubmitViewController else {
return
}
destination.john = accountType