---
title: environment
framework: swiftui
role: symbol
role_heading: Instance Property
path: swiftui/nshostingscenerepresentation/environment
---

# environment

The environment for any scene(s) being represented by self.

## Declaration

```swift
@MainActor var environment: EnvironmentValues { get }
```

## Discussion

Discussion Use the environment values to programmatically present a scene’s window. For example, you can present the window for a Settings scene using OpenSettingsAction when a menu item is selected: let settingsScene = NSHostingSceneRepresentation {     Settings {         SettingsView()     } }

@IBAction func showAppSettings(_ sender: NSMenuItem) {     settingsScene.environment.openSettings() }
