Not really. I found a way to unload and reload my persistence stores. But my App crashes because the old viewContext is still used in the view hierarchy.
Therefore, I tried to completely unload my root view (ContentVIew) by switching to another view. But the ContentView() won't be released from memory, even if it is not shown.
@StateObject private var appRootManager = AppRootManager()
var body: some Scene {
WindowGroup {
Group {
switch appRootManager.currentRoot {
case .splash:
SplashView()
case .reloading:
StatusView()
case .ready:
ContentView()
}
.environmentObject(appRootManager)
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: