aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/ViewControllers/Identifyable.swift
blob: c94a3995ca6ced6f7c0d9cbcdbc9908176a795c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//
//  Copyright © 2018 WireGuard LLC. All rights reserved.
//

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
    }
}