//
// © 2017-2020 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
//

import UIKit

protocol StoryboardInstantiation {}

extension StoryboardInstantiation {
    static func instantiateFromStoryboard(name: String = "Main") -> Self {
        let className = String(describing: self)
        let storyboard = UIStoryboard(name: name, bundle: nil)
        guard let viewController = storyboard.instantiateViewController(withIdentifier: className) as? Self else {
            fatalError("Cannot instantiate \(className) from \(name)")
        }
        return viewController
    }
}

extension UIViewController: StoryboardInstantiation {}
