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

# NSViewRepresentableContext

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

```
@MainActor @preconcurrency struct NSViewRepresentableContext<View> where View : NSViewRepresentable
```

## Overview

An [`NSViewRepresentableContext`](/documentation/SwiftUI/NSViewRepresentableContext) structure contains details about the
current state of the system. When creating and updating your view, the
system creates one of these structures and passes it to the appropriate
method of your custom [`NSViewRepresentable`](/documentation/SwiftUI/NSViewRepresentable) instance. Use the information
in this structure to configure your view. For example, use the provided
environment values to configure the appearance of your view. Don’t create
this structure yourself.

## Topics

### Coordinating view-related interactions

[`let coordinator: View.Coordinator`](/documentation/SwiftUI/NSViewRepresentableContext/coordinator)

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

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

The current transaction.

### Getting the current environment data

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

Environment data that describes the current state of the system.

### Instance Methods

[`func animate(changes: () -> Void, completion: (() -> Void)?)`](/documentation/SwiftUI/NSViewRepresentableContext/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)