0

The code below is a segue that worked before updating my code to iOS 10 SDK and Swift 3, and now doesn't work, giving an EXC_I386_INVOP error in the file the assignment is supposed to be passed to.

func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
    isEditing = false
    if segue.identifier == "ShowAssignment" {
        let HWDetailViewController = segue.destination as! DailyHWViewController

        // Get the cell that generated this segue.
        if let selectedGradeCell = sender as? HWListCell {
            let indexPath = tableView.indexPath(for: selectedGradeCell)!
            let selectedAssignment = assignments[(indexPath as NSIndexPath).row]
            HWDetailViewController.assignment = selectedAssignment
            print(selectedAssignment.date)
        }
    }
}

It seems as if it just isn't passing the assignment, because based the 'print' does print the date correctly but does not print when the print statement is in the file the assignment is supposed to be passed to, giving the same error. Was there a change made in Swift 3 to segues that I'm unaware of? Thanks!

EDIT: The three last lines in the view controller that is segued to give the error.

var assignment: Assignment!


//MARK: Functions

override func viewDidLoad() {
    super.viewDidLoad()

    self.navigationItem.setHidesBackButton(true, animated:true);

    print(assignment.date)
    textField.text = assignment.hw
    navBar.title = assignment.date

}
Aej11
  • 57
  • 6

0 Answers0