wip
This commit is contained in:
@ -13,23 +13,21 @@ import SwiftData
|
||||
|
||||
@main
|
||||
struct WorkoutsApp: App {
|
||||
var sharedModelContainer: ModelContainer = {
|
||||
let schema = Schema([
|
||||
Item.self,
|
||||
])
|
||||
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
|
||||
|
||||
do {
|
||||
return try ModelContainer(for: schema, configurations: [modelConfiguration])
|
||||
} catch {
|
||||
fatalError("Could not create ModelContainer: \(error)")
|
||||
let container: ModelContainer
|
||||
|
||||
init() {
|
||||
var shouldCreateDefaults = false
|
||||
self.container = WorkoutsContainer.create(shouldCreateDefaults: &shouldCreateDefaults)
|
||||
|
||||
if shouldCreateDefaults {
|
||||
InitialData.create(modelContext: ModelContext(container))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
}
|
||||
.modelContainer(sharedModelContainer)
|
||||
.modelContainer(container)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user