Group Group Group Group Group Group Group Group Group

UIKit, unwanted SceneDelegate, can't reference window in AppDelegate

Using iOS_Apprentice_v7.0 to follow along with UIKit as I’m not currently a fan of SwiftUI.

Got Stuck with Xcode 11.4.1 which auto generates the split AppDelegate and SceneDelegates.

Trying to reference window in AppDelegate is nil.

iOS_apprentice_v8.2.1 “When you switch to building apps with the UIKit framework later in this book, you’ll only see AppDelegate.swift” This is not true.

iOS_apprentice_v8.2.1 Page 503: “Most importantly: Uncheck the Use SwiftUI checkbox! This is how you tell Xcode you’re going to create a UIKit based app.” There is no checkbox, only the dropdown of SwiftUI or Storyboard. Storyboard still makes a SceneDelegate File.

Just downloaded iOS_Apprentice_v8.3.0. Looks like others also prefer UIKit which is now introduced initially unlike iOS_apprentice_v8.2.1 which switched from SwiftUI later in the book. Screenshot on page 219 doesn’t show SceneDelegate however, when I do the same setup, Single View, with Swift and Storyboard I get the SceneDelegate file.

iOS_Apprentice_v8.3.0 Chapter 17, P432: “The ideal place for handling app termination notifications is inside the scene delegate. You haven’t spent much time with this object before, but every app has one.” - when I open the starter and final source codes for Chapter 17 Improved Data Model, neither have a SceneDelegate.

How do I just stick with UIKit and not produce a SceneDelegate file and be able to reference window in AppDelegate. Thanks

Solved: SceneDelegate.swift needs to stay and you just use the “willConnectTo” function in this file instead of the “application(_:didFinishLaunchingWithOptions:)” in AppDelegate.swift.

There is some confusion because the latest iOS_Apprentice_v8.3.0 has mixed up the function name which doesn’t match the method code provided. Page 700 says:

➤ Change the application(_:didFinishLaunchingWithOptions:) method to:

func scene(_ scene: UIScene,
willConnectTo session: UISceneSession
options connectionOptions: UIScene.ConnectionOptions) {