I have a model class with various status values that I would like to store in a single 64 bits integer. For example one bit for this boolean flag, 4 bits for that lookup value and so on.
I tried to create a predicate containing bitwise operators to query specific bits but that seems impossible, no way no compile it.
is there a way I am no aware of to accomplish this, some workaround or is that planned to be possible in future Swiftdata release?
that would be a shame having to store a few status values of 4 or less bits each in different 64bits values, what a waste!
Thanks
Tof
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,
I am developing a multi platform application using SwiftData.
Since a few days, when running the macOS version I cannot create the model container while on iOS everything is fine.
On macOS I receive the error :
Thread 1: Fatal error: Could not create ModelContainer: SwiftDataError(_error: SwiftData.SwiftDataError._Error.loadIssueModelContainer)
The code that initialize the model container is :
let schema = Schema([
Account.self,
ABCategory.self
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do {
let container = try ModelContainer(for: schema, configurations: [modelConfiguration])
container.mainContext.undoManager = UndoManager()
return container
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}
var body: some Scene {
WindowGroup {
ContentView(accuBalanceModel: accuBalanceModel)
}
.modelContainer(sharedModelContainer)
//.modelContainer(for: [Account.self, ABCategory.self], inMemory: false, isUndoEnabled: true)
#if os (OSX)
//
// Remove the 'New Window' menu item.
//
.commands {
CommandGroup(replacing: CommandGroupPlacement.newItem) {
}
}
#endif
}
I can say that the model has no issues as it works when running on IOS and also, if I
change inMemory: false with inMemory: true the macOS version succeed in creating the model.
I can also say this is not a network issue as the Mac and the iOS device running the application are connected to the same box.
The Xcode version is Version 15.2 (15C500b)
Ios device where everything is fine : iPhone 11 OS 17.3.1 (21D61)
the Mac device : Mac mini M1 2020 : 14.0 (23A344)
Any advice to resolve that problem would be greatly appreciated.
Best Regards
Christophe Lestrade
I am developing a SwiftData application using CloudKit.
I have been playing with the app for a while and populated the database.
Recently I decided to change the type of an attribute. So I reseted the scheme in CloudKit Console to the production one, which actually is empty for now, so I restart from scratch.
Unfortunatly, the locally cached database on my Mac is using the old schema and my app fails loading the ModelContainer because of the type incompatibilities.
I would like to delete the locally cached database but I haven't a clue of where it can be. I do not want to go through a migration plan for that.
Does someone know where can I find it ?
Chris tof