So I have a ViewController that navigates to another one when didSelectRowAt is called. I navigate to the new view controller as such:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let accountInsightsViewController:AccountInsightsViewController = AccountInsightsViewController(nibName: "AccountInsightsViewController", bundle: nil)
accountInsightsViewController.accountDetailsObjectFromSourceController = self.accountDetailsObjectFromSourceController
accountInsightsViewController.accountDetailsObjectFromSourceController["accountId"] = self.accountDetailsObjectFromSourceController["accountId"]
if let navigator = navigationController {
navigator.pushViewController(accountInsightsViewController, animated: true)
}
}
However, in this new view controller's viewDidLoad()
function, the attribute accountDetailsObjectFromSourceController
becomes an empty dictionary again. When I debug, I can clearly see that when I set this attribute dictionary to dictionary of the same structure, it happens to properly set the value of the dictionary to the dictionary with 3 key/value pairs. However, when the navigationController pushes this VC, it crashes because this dictionary has 0 key/value pairs inside the new VC's viewDidLoad()
Would someone be able to tell me why the value is being set, but when it navigates to this VC, the dictionary is then empty? The view controller comes in the form of its own XIB file and VC Swift file. Clearly I am doing the right thing, and it hits the viewDidLoad()
, but why won't it take the value that I set right before pushViewController
?