Contents

NSHostingController

An AppKit view controller that hosts SwiftUI view hierarchy.

Declaration

@MainActor @preconcurrency class NSHostingController<Content> where Content : View

Overview

Create an NSHostingController object when you want to integrate SwiftUI views into an AppKit view hierarchy. At creation time, specify the SwiftUI view you want to use as the root view for this view controller; you can change that view later using the rootView property. Use the hosting controller like you would any other view controller, by presenting it or embedding it as a child view controller in your interface.

Topics

Creating a hosting controller object

Getting the root view

Configuring the controller

See Also

Displaying SwiftUI views in AppKit