ios – UIWindow in SceneDelegate

[ad_1]

Just lately, I encountered an issue, which I’ve posted right here, in stackoverflow. Apparently, the error was as a result of a random UIWindow variable was used to show UI (and never the one in SceneDelegate).

Here is my understanding – Each time a scene is created (by consumer or the app), a UISceneSession is created to handle a UIScene, which might include a number of UIWindows, every of which has views, that are displayed with the assistance of a view controller. Every UIScene will get a UISceneDelegate object to deal with its lifecycle.

The error in my earlier publish is sensible now – since a random UIWindow object was used as an alternative of the one in SceneDelegate.

However I nonetheless do not fully perceive why a UIWindow was declared within the SceneDelegate by Xcode. There is a UIWindow object in UIWindowSceneDelegate (tremendous class of my present SceneDelegate) and the documentation clearly explains that its a window related to the scene.
Why is not that used and as an alternative a brand new variable is created by Xcode whereas creating the mission? If I want one other window, then can I simply add one other UIWindow object to the present SceneDelegate? Is {that a} good follow?

@accessible (iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    
    var window: UIWindow?

    // Remaining strategies
}

I am new to swift and iOS app growth – any assist to fill in these blanks can be enormously appreciated.

[ad_2]

Leave a Reply