wireguard-apple/WireGuard/ViewControllers/Identifyable.swift

28 lines
671 B
Swift
Raw Normal View History

2018-05-23 19:49:10 +00:00
//
// Identifyable.swift
// WireGuard
2018-05-23 19:49:10 +00:00
//
// Created by Jeroen Leenarts on 23-05-18.
2018-07-15 09:55:41 +00:00
// Copyright © 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All rights reserved.
2018-05-23 19:49:10 +00:00
//
import Foundation
import UIKit
public protocol Identifyable: class {
static var identifier: String { get }
}
public extension Identifyable {
static var identifier: String {
return String(describing: Self.self)
}
}
extension UIStoryboard {
public func instantiateViewController<T: Identifyable>(type: T.Type) -> T where T: UIViewController {
return self.instantiateViewController(withIdentifier: type.identifier) as! T // swiftlint:disable:this force_cast
}
}