Skip to content

Instantly share code, notes, and snippets.

@nvkiet
Last active August 29, 2015 14:03
Show Gist options
  • Save nvkiet/9f6e8432e6bb329f300a to your computer and use it in GitHub Desktop.
Save nvkiet/9f6e8432e6bb329f300a to your computer and use it in GitHub Desktop.
Init a subview
Also for people referring to @akashivskyy answer, and having trouble or crash with error
fatal error: use of unimplemented initializer 'init(coder:)' for class
Implementing initWithCoder in Objective-C is not required but in Swift is required
So to use @akashivskyy's asnwer you need also to add these lines to your destinationViewController.
init(coder aDecoder: NSCoder!)
{
super.init(coder: aDecoder)
}
or removing this at your destinationViewController, let's Swift inherit all superclass methods including the one I wrote above!
init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
// Here you can init your properties
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment