Files
eqn.ios/Sources/Earthquake Network/Libs/StoryboardInitializable.swift
T

26 lines
753 B
Swift

//
// StoryboardInitializable.swift
//
// Created by Busi Andrea on 10/11/2020.
//
import Foundation
protocol StoryboardInitializable where Self: UIViewController {
static var storyboardName: String { get }
static var storyboardControllerId: String { get }
static func makeController() -> Self
}
extension StoryboardInitializable {
static func makeController() -> Self {
let storyboard = UIStoryboard(name: storyboardName, bundle: Bundle(for: Self.self))
guard let controller = storyboard.instantiateViewController(withIdentifier: storyboardControllerId) as? Self else {
fatalError("Unable to instantiate controller with anem \(storyboardControllerId)")
}
return controller
}
}