1
votes

After updating from Xcode 8 beta 5 to Xcode 8 final release, and after removing the override from all my prepare for segue methods, all of them are crashing at run time.

Here is an example of my code:

This is the action method for the button:

@IBAction func actionRequested(_ sender: AnyObject) {

    if sender as! UIButton == shoppingButton
    {
        print("executed from inside of actionRequested Method")
        performSegue(withIdentifier: "toShopping", sender: self)
    }
}

This is the prepare for segue method.

// MARK: - Navigation
func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
    print("executed from inside of prepare For segue method")
    if segue.identifier == "toShopping"
    {
        let newHomeViewController = segue.destination as!  HomesTableViewController
        newHomeViewController.profile = self.profile
    }

}

This is the error:

executed from inside of actionRequested Method
fatal error: unexpectedly found nil while unwrapping an Optional   value
2016-09-16 10:30:06.194590 Fredi[2567:551009] fatal error: unexpectedly found nil while unwrapping an Optional value  

Note that all my prepare for segue methods were working before removing the override, and now I get the same error in all of them. Anyone could point me in the right direction to solve this ?

Thank you in advance.

2
I already did it. Thanks for the suggestion.Jose Ortiz Costa

2 Answers

2
votes

Don't remove the override, you're hiding the issue instead of fixing it. The signature of the prepare for segue method changed in Xcode 8 beta 6.

It should now be:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
0
votes

I, finally, solved it reinstalling Xcode and using the method signature proposed by Dan.

Thank you for your responses.