I haven't tried this out but I think it should work something like that:
Create in your parent view the new context.
let container = try! ModelContainer(for: Model.self,
ModelConfiguration(inMemory: true)) // or whatever works for you
let localContext = ModelContext(container)
Then attach the localContext to a child view.
yourView
.modelContext(localContext)
In the child view you should have access to it via the environment.
@Environment(\.modelContext) var modelContext
If you want to use the same container like your original context, try originalContext.container and use that in step 1.
@Query in the child view will work on the given model context.
At least this is my theory. I don’t have time to check it, but maybe it helps you anyways.
Post
Replies
Boosts
Views
Activity
To be honest, I don’t know what you mean by that.
It’s hard to tell from your screenshots but I think you need to add the frameworks to the target. Under General > Frameworks, Libraries and Embedded Content hit the + Button and add the frameworks.
When you use resources from a localised framework, make sure to use methods with the bundle: parameter! Even in the framework itself.
Instead of using String(localized: "some String") use String(localized: "some String", bundle: Bundle.module). Same goes for Color, NSDataAsset and so on. This fixed my issue.
Thanks!
The type .import is exactly what I was looking for. For my use case it is absolutely sufficent to inspect the end date of this event type. Once it is not nil I know the import is finished and I can do what I need to do.