So Xcode fought me on the storyboard thing, first by saying .main()
doesn't exist then by...well, my initial view controller is the tab controller for the application, followed by a nav controller for the tab content, then the first tab's content. So getting to a compatible view controller using that method didn't seem to work.
I've tried applying the same principles slightly differently, however, as shown in the following example. Basically, I created a SubViewController
class as a thin wrapper for the SubView
, then instantitated a controller directly using it. I tried setting the container to the SubViewController
class, but Interface Builder rejected that and set it back to SubView
.
In the end, however, it's still dealing with the same issue: bailing out whenever the properties of the view are invoked, even though we established the child view and added it...
/* == Storyboard Content==
Added to MainViewController:
* Container Object: subView (changed class to SubView, connected to corresponding IBOutlet, rebuilt view inside the view that came with the container)
== END Storyboard Content== */
class MainViewController: UIViewController {
@IBOutlet weak var subView: SubView!
override func viewDidLoad() {
super.viewDidLoad()
/// Configure Subviews
let vc = QuestionViewController()
vc.setupView()
questionView = vc.view as? QuestionView
addChild(vc)
questionViewContainer.addSubview(vc.view!)
vc.didMove(toParent: self)
/// Error appears here
subView.propertyName = "value"
}
}
class SubViewController: UIViewController {
func setupView() {
view = SubView()
}
}
class SubView: UIView {
var propertyName: String?
}