Post

Replies

Boosts

Views

Activity

Bitwise operators in predicate with SwiftData
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
0
1
321
Apr ’24
How to clear locally cached SwiftData database on macOS
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
1
0
1.7k
Mar ’24
Load issue on SwiftData model container on macOS and not iOS
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
1
0
1.3k
Mar ’24
SwiftUI Drag image OK on macOS but KO on iPadOS
Hello.I am implementing a SwiftUI Drag and Drop application which runs fine on both macOX and IpadOS.The only problem I have is that on iPadOS, the Dragged image is rendered just as an empty rectangle, while on macOS I have a correct dragged image.The body of the view from which the items are dragged is : var body: some View { HStack { ForEach( libraryRowItems, id: \.self) { thelibraryItem in libraryItemView(item: thelibraryItem) .onDrag { return NSItemProvider(object: NuageIdentifier(identifier:thelibraryItem.id)) } } } }and the body for libraryItemView : var body: some View { let topColorGradient = Color(Color.RGBColorSpace.sRGB, red: 0.298, green: 0.301, blue: 0.301); let bottomColorGradient = Color(Color.RGBColorSpace.sRGB, red: 0.235, green: 0.239, blue: 0.239); return ZStack { RoundedRectangle(cornerRadius: 5) .fill(LinearGradient(gradient: Gradient(colors: [topColorGradient, bottomColorGradient]), startPoint: .top, endPoint: .bottom)) Text("\(text)").foregroundColor(.white).font(.custom("STIX2Math", size: fontSize)) } .frame(width:50, height: 33) }On my late 2013 mac everything is okOn my Ipad 5th generation the dragged iage is just a rectangle.My mac is unable to run it on a Simulator (seems to be too slow now) to see if it could depends on the generation of the device.I am the only one to encounter this problem ?RegardsChris Tof
3
0
1.9k
Mar ’20