Fidelity Investments interview question

What is @State, @StateObject, @EnvironmentObject?

Interview Answer

Anonymous

25 Oct 2024

@State: When that state changes, SwiftUI knows to automatically reload the view with the latest changes so it can reflect its new information. @StateObject: This is very similar to @State except now we’re using an external reference type rather than a simple local property like a string or an integer. @EnvironmentObject: This is a value that is made available to your views through the application itself – it’s shared data that every view can read if they want to.