Skip to content

Instantly share code, notes, and snippets.

@kiarashvosough1999
Created June 30, 2022 18:49
Show Gist options
  • Save kiarashvosough1999/69525017537c0165326f74c117adcfed to your computer and use it in GitHub Desktop.
Save kiarashvosough1999/69525017537c0165326f74c117adcfed to your computer and use it in GitHub Desktop.
Scene Manager
import UIKit
final class SceneManager {
var activityIdentifier: ActivityIdentifier? {
options
.userActivities
.compactMap { ActivityIdentifier(rawValue: $0.activityType) }
.first
}
private let options: UIScene.ConnectionOptions
init(with options: UIScene.ConnectionOptions) {
self.options = options
}
func generateUISceneConfiguration() -> UISceneConfiguration {
let identifier = activityIdentifier ?? .mainApp
switch identifier {
case .mainApp:
return generateMainAppConfig(with: identifier.rawValue)
}
}
fileprivate func generateMainAppConfig(with identifier: String) -> UISceneConfiguration {
let config = UISceneConfiguration(name: identifier + " Configuration",
sessionRole: .windowApplication)
config.delegateClass = MainAppSceneDelegate.self
return config
}
}
extension SceneManager {
enum ActivityIdentifier: String {
case mainApp
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment