I am trying to access the previous viewcontroller in a navigation stack. I want to set a label's text property before I pop back to it. It crashes after the second line in the function. Thanks for any help.
func goBack(){
let i = (navigationController?.viewControllers.count)! - 1
let itemViewController = navigationController?.viewControllers[i] as ItemViewController
itemViewController.typeValueLbl.text = itemName
navigationController?.popViewControllerAnimated(true)
}