Created
September 23, 2018 21:25
-
-
Save MaciejGad/d071833e8affff97b3c52c48ed48bcab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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