Skip to content

Instantly share code, notes, and snippets.

@juliancadi
Last active June 23, 2023 09:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliancadi/370616e217ded71febbf5b96ecf788dc to your computer and use it in GitHub Desktop.
Save juliancadi/370616e217ded71febbf5b96ecf788dc to your computer and use it in GitHub Desktop.
Nibless UIViewController in favor of initializer dependency injection.
import UIKit
open class NiblessViewController: UIViewController {
public init() {
super.init(nibName: nil, bundle: nil)
}
@available(*, unavailable,
message: "Loading this view controller from a nib is unsupported in favor of initializer dependency injection."
)
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
@available(*, unavailable,
message: "Loading this view controller from a nib is unsupported in favor of initializer dependency injection."
)
public required init?(coder aDecoder: NSCoder) {
fatalError("Loading this view controller from a nib is unsupported in favor of initializer dependency injection.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment