I have this:
guard let mapVC = mapSB.instantiateInitialViewController() else { return }
mapVC.navigationItem.title = "Some title string"
// (mapVC as! MapViewController).string = "Some string"
// (mapVC.navigationController?.viewControllers.first as! MapViewController).string = "Some string"
I have tried both of the commented out lines, but it crashes on whichever line I comment back in. And here is the po of mapVC:
po mapVC
error: <EXPR>:3:1: error: use of unresolved identifier 'mapVC'
mapVC
^~~~~~~~~
Which is weird, because it does correctly set the mapVC.navigationItem.title as "Some title string."
If this helps, mapVC is embedded in a navigation controller in mapSB.
Edit:
The crash message is:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
And mapVC is of type MapViewController, hence the casting.