1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/ui-macos/WindowsManager.swift
2019-09-30 10:19:29 +01:00

29 lines
845 B
Swift

//
// WindowsManager.swift
// lokinet
//
// Copyright © 2019 Loki. All rights reserved.
//
import AppKit
import Foundation
struct WindowsManager {
static func getVC<T: NSViewController>(withIdentifier identifier: String,
ofType: T.Type?,
storyboard: String = "Main",
bundle: Bundle? = nil) -> T? {
let storyboard = NSStoryboard(name: storyboard, bundle: bundle)
guard let vc: T = storyboard.instantiateController(withIdentifier: identifier) as? T else {
let alert = NSAlert()
alert.alertStyle = .critical
alert.messageText = "Error initiating the viewcontroller"
alert.runModal()
return nil
}
return vc
}
}