0

Suppose i have a ABC : UIViewController. I would like to make it a Singleton class, as this view can be launched from various places in my app.

I started coding as below, but not sure how to proceed:

public static sharedInstance 

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
    super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}
dan
  • 9,695
  • 1
  • 42
  • 40
  • 1
    A view controller doesn't need to be a singleton to show it from various places in your app. – dan Mar 09 '17 at 22:56
  • If you are mainly concerned with passing data around, then you can have a singleton class instead. But like @dan said, there's no need to make the VC a singleton – Sylvan D Ash Mar 09 '17 at 22:58
  • is it recommended to make uiviewcontroller as a singleton class? – justCurious Mar 09 '17 at 23:00
  • To be more precise, you *should not* use a singleton VC as it is quite likely that state manipulations would get confused. – David Berry Mar 09 '17 at 23:01

0 Answers0