Post

Replies

Boosts

Views

Activity

Reply to Is that possible to update ModelContainer?
Thank you, I tried, and I think the key is modelContainer(_:) method Now I have login and register view inside my MainScreenView. MainScreenView is the top View, which uses modelContainer(_:) method inject the container to the View, and the container is saved in a singleton actor. So the injection is finished right now, although I changed the container in singleton actor, that's the reason it won't affect anything. I think what I should do is, separate the inject, rearrange the hierarchy, make sure when MainScreen is open it could access the new Container, am I right? BTW, I have some data which happened before register, when registration is done, I want to save that data to a new Container, and I got illegal inject error. So it's not possible to save the model data from another ModelContext to a new ModelContext, is that right? I should save them to another format then transfer to Model Data.
Nov ’25