Created
April 19, 2024 08:00
-
-
Save tunds/535a07293766b6fa2d4171ff88625a4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftData | |
actor ItemsContainer { | |
@MainActor | |
static func create(shouldCreateDefaults: inout Bool) -> ModelContainer { | |
let schema = Schema([Item.self]) | |
let isPaidUser = true // Write your logic here to see if they've paid or not | |
let configuration = ModelConfiguration(cloudKitDatabase: isPaidUser ? .automatic : .none) | |
let container = try! ModelContainer(for: schema, | |
migrationPlan: ToDosMigrationPlan.self, | |
configurations: [configuration]) | |
return container | |
} | |
} | |
/********/ | |
@main | |
struct MyApp: App { | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
.modelContainer(ItemsContainer.create()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment