To use EnvironmentObject, you have to attach the modifier .environmentObject(Model()) to ContentView() which is in struct ImageRendererWithEnvironmentApp.
Like below,
import SwiftUI
@main
struct ImageRendererWithEnvironmentApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(Model()) // You have to add this.
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: