SwiftUI : SceneDelegate

버들비·2020년 8월 3일
0

at SceneDelegate.swift

// Create the SwiftUI view that provides the window contents.
        let contentView = ContentView()

        // Use a UIHostingController as window root view controller.
        if let windowScene = scene as? UIWindowScene {
            let window = UIWindow(windowScene: windowScene)
            window.rootViewController = UIHostingController(rootView: contentView)
            self.window = window
            window.makeKeyAndVisible()
        }

contentView 인스턴스를 생성하고, UIHostingController 의 rootView 매개변수에 전달한다.

UIHostingController 정의

open class UIHostingController<Content> : UIViewController where Content : View

UIViewController 를 상속받고, 뷰 프로토콜을 준수하는 제네릭 매개변수 Content를 전달받는 제네릭 클래스.

0개의 댓글