April 11, 2025

They mentioned about how to store an observable object instead of passing from upstream

https://developer.apple.com/documentation/swiftui/state#Store-observable-objects


https://developer.apple.com/forums/thread/739163

iOS 17 introduced @Observable. that's an effective way to implement a stateful model object.

Seems there is no way to associate instances with views

However, we are not able to use @StateObject as the model object does not have ObservableObject protocol. An advantage of using @StateObject is to make the object initialized once only for the view. It will keep going on until the view identifier is changed.

I put some examples. We have an Observable implemented object.

@Observable final class Controller { ... }

then using like this