You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@madhavajay I understand the motivation for this, but the issue is a bit more complex than it first seems. Our various reusable parts under UIComponents all take a parentVC: BaseViewController in their init function. This makes sense semantically, because each of these parts demands a parent ViewContoller in order to be drawn on the screen. It also turned out to be necessary in order to add MenuItems to the Menu that trigger a segue in its init function.
At first I thought I would just instantiate them with default values in each subclass of BaseViewController, but that doesn't work because they need to take a BaseViewController in their init, which means that the BaseViewController's init needs to be called first. So then I tried making a call to super.init() in each BaseViewController, but then the compiler started complaining to me that I needed to implement this init function as well, alongside my custom init:
But when I implement that init function, the compiler starts complaining that "Property '' not initialized at super.init call". But again its not possible to initialize it before the super.init, because the UIComponent needs the BaseViewController instance passed to it in order to be initialized.
So the compromise I came up with was to make those all IOUs! that get initialized in viewDidLoad (or, in the case of BaseViewController, in viewDidLayoutSubviews, for an idiosyncratic iOS platform reason related to when the struct denoting the Safe Area gets filled in). The ! denotes that this object should indeed be there for all intents and purposes, its only an "optional" for this convoluted chain of reasons, but you should expect it to be there. The other option was to make it Optional? and use a ton of ?'s everywhere, but that was ugly both in code and violated the semantics of Optional
class BaseViewController: UIViewController {
var header: Header!
The text was updated successfully, but these errors were encountered: