Skip to content

Instantly share code, notes, and snippets.

@jsorge
Created May 7, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsorge/f9499795cb82bbffe06e17fad276c274 to your computer and use it in GitHub Desktop.
Save jsorge/f9499795cb82bbffe06e17fad276c274 to your computer and use it in GitHub Desktop.
Nibless View Controller
//: Playground - noun: a place where people can play
import UIKit
class ViewController: UIViewController {
init() {
super.init(nibName: nil, bundle: nil)
}
@available(*, unavailable, message: "Loading this view controller from a nib is unsupported.")
override convenience init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
self.init()
}
@available(*, unavailable, message: "Loading this view controller from a nib is unsupported.")
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class ListViewController: ViewController {
let list: [String]
init(list: [String]) {
self.list = list
super.init()
}
}
let vc = ListViewController(list: ["hello", "world"])
print(vc.list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment