uiviewcontroller - Instantiating and pushing view controller programmatically with custom initializer swift -
I want to present a detailed view controller in much like faster
go to detailController = MyDetailUIViewController (nibName: "MyDetailUIViewController", Bundle: NSBundle.mainBundle (), Data: MyData)? Self.navigationController .pushViewController (detailController, animated: true) The issue I am doing is how to write my initiator for MyDetailViewController:
class MyDetailUIViewController: UIViewController {Private data on: MyData init (nibName nibNameOrNil: string !, bundle nibBundleOrNil: NSBundle !, Data: MyData) {self.data = data super.init (nibName: nibNameOrNil, bundle: nibBundleOrNil)} required init ( Coder aDecoder: NSCoder) {super.init (coder: aDecoder)} An error I'm getting my data Property has not been started on super intra call. Can anyone explain how I can complete it? I'm sure that I can make my data assets optional and pass that in after the initialization, but there is definitely a way to do this work.
After the
If you declare your data variable non-optional, then You must make sure that all init methods start it since it is not in its class since
required init (coder aDecoder: NSCoder) {Super.init (encoder: aDecoder)} does not adhere to your data .
Comments
Post a Comment