Generic Structure


Contextual information about the state of the system that you use to create and update your AppKit view controller.


struct NSViewControllerRepresentableContext<ViewController> where ViewController : NSViewControllerRepresentable


An NSViewControllerRepresentableContext structure contains details about the current state of the system. When creating and updating your view controller, the system creates one of these structures and passes it to the appropriate method of your custom NSViewControllerRepresentable instance. Use the information in this structure to configure your view controller. For example, use the provided environment values to configure the appearance of your view controller and views. Don't create this structure yourself.


Coordinating View-Related Interactions

let coordinator: ViewController.Coordinator

An object you use to communicate your AppKit view controller's behavior and state out to SwiftUI objects.

var transaction: Transaction

The current transaction.

Getting the Current Environment Data

var environment: EnvironmentValues

Environment data that describes the current state of the system.

See Also

Creating and Updating the View Controller

func makeNSViewController(context: Self.Context) -> Self.NSViewControllerType

Creates the view controller object and configures its initial state.


func updateNSViewController(Self.NSViewControllerType, context: Self.Context)

Updates the state of the specified view controller with new information from SwiftUI.


associatedtype NSViewControllerType

The type of view controller to present.