You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/ui-macos/WindowsManager.swift

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