Why is AppDelegate.swift window an optional?

后端 未结 3 2074
灰色年华
灰色年华 2020-12-14 03:47

I was reading Apple docs, when I found this sentence:

The AppDelegate class contains a single property: window.

va

3条回答
  •  自闭症患者
    2020-12-14 04:00

    You may not always need it. For example, when these two methods are called :

    application(_:performFetchWithCompletionHandler:)
    application(_:handleEventsForBackgroundURLSession:completionHandler:)
    

    your app will not be shown to the user, so there is no need for a window.

    As always, more in the docs

    Now, I'm not sure that this is the inherent reason, but it seems as a good enough possibility (at least for me). Though if someone is able to provided some more information, I'd gladly learn some more also.

提交回复
热议问题