How to access SceneDelegate from NSObject?

Viewed 980

I declared a variable in sceneDelegate and want to access that variable from the NSObject. We can do that from UIView or UIViewController, but don't know how to do this in NSObject.

Is there a way to access this variable?

1 Answers

If you have only one scene in application it is possible to do with

if let delegate = UIApplication.shared.connectedScenes.first?.delegate as? Your_SceneDelegate_Class {
    // ... access anything needed in delegate
}
Related