---
title: "environmentObject(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/scene/environmentobject(_:)"
---

# environmentObject(_:)

Supplies an ObservableObject to a view subhierarchy.

## Declaration

```swift
nonisolated func environmentObject<T>(_ object: T) -> some Scene where T : ObservableObject

```

## Parameters

- `object`: The object to store and make available to the scene’s subhierarchy.

## Discussion

Discussion The object can be read by any child by using EnvironmentObject: final class Profile: ObservableObject { ... }

@main struct MyApp: App {     var body: some View {         WindowGroup {             ContentView()         }         .environment(ProfileService.currentProfile)     } } You then read the object inside ContentView or one of its descendants using the EnvironmentObject property wrapper: struct ContentView: View {     @EnvironmentObject private var currentAccount: Account

var body: some View { ... } }

## See Also

### Distributing model data throughout your app

- [environmentObject(_:)](swiftui/view/environmentobject(_:).md)
- [EnvironmentObject](swiftui/environmentobject.md)
