<!--
{
  "availability" : [
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/NSViewControllerRepresentableContext",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI36NSViewControllerRepresentableContextV"
  },
  "title" : "NSViewControllerRepresentableContext"
}
-->

# NSViewControllerRepresentableContext

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

```
@MainActor @preconcurrency struct NSViewControllerRepresentableContext<ViewController> where ViewController : NSViewControllerRepresentable
```

## Overview

An [`NSViewControllerRepresentableContext`](/documentation/SwiftUI/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`](/documentation/SwiftUI/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.

## Topics

### Coordinating view-related interactions

[`let coordinator: ViewController.Coordinator`](/documentation/SwiftUI/NSViewControllerRepresentableContext/coordinator)

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

[`var transaction: Transaction`](/documentation/SwiftUI/NSViewControllerRepresentableContext/transaction)

The current transaction.

### Getting the current environment data

[`var environment: EnvironmentValues`](/documentation/SwiftUI/NSViewControllerRepresentableContext/environment)

Environment data that describes the current state of the system.

### Instance Methods

[`func animate(changes: () -> Void, completion: (() -> Void)?)`](/documentation/SwiftUI/NSViewControllerRepresentableContext/animate(changes:completion:))

Animates changes using the animation in the current transaction.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)