Skip to content

Instantly share code, notes, and snippets.

@MaciejGad
Created September 23, 2018 21:25
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 MaciejGad/d071833e8affff97b3c52c48ed48bcab to your computer and use it in GitHub Desktop.
Save MaciejGad/d071833e8affff97b3c52c48ed48bcab to your computer and use it in GitHub Desktop.
//
// NibBaseViewController.swift
//
// Created by Maciej Gad on 23/09/2018.
// Copyright © 2018 Maciej Gad. All rights reserved.
//
import Foundation
import UIKit
class NibBaseViewController: UIViewController {
required init() {
let classNameComponents = NSStringFromClass(type(of: self)).components(separatedBy: ".")
guard let className = classNameComponents.last else {
fatalError("Bad class name: \(classNameComponents)")
}
let bundle = Bundle(for:type(of:self))
guard bundle.path(forResource: className, ofType: "nib") != nil else {
fatalError("No nib file for \(className)")
}
super.init(nibName:className, bundle: bundle)
}
@available(*, unavailable, message: "don't use sotryboard! use nib and init()")
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment