Another nice solution is to declare the new initializer as a convenience initializer as follows:
convenience init( objectId : NSManagedObjectID ) { self.init()
If you do not specify designated initializers at all in your subclass, they are inherited automatically, and you can use self.init() in your convenient initializer.
In the case of the UIViewController, the init method will call init by default init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) With nil for both arguments (Command-Click on the UIViewController will give you this information).
TL; TR . If you prefer to programmatically work with the UIViewController , here is a complete working example that adds a new initializer with a custom argument:
class MyCustomViewController: UIViewController { var myString: String = "" convenience init( myString: String ) { self.init() self.myString = myString } }
Klaas Aug 15 '14 at 2:41 2014-08-15 14:41
source share