Post

Replies

Boosts

Views

Activity

Comment on
When I tested this I didn't use model(for:) since I already had access to the object and then isDeleted was set to true after the deletion. This looks like an issue with SwiftData that. you might want to file a report about but as far as real world programming goes your example code looks quite contrived and I don't see why you would want to do something like this.
May ’25
Comment on modelContext.fetch() hits assert on release builds, but not on debug builds
Hi My question had nothing to do with the assert, I just wanted to understand the code better since the non-generic version worked and now I understand it better. I don't know if you are interested in testing this but I was thinking that maybe it's the associated type that causes the issues so one alternative to get would be to use MyModelProtocol instead for the generic type func addRecord<T: MyModelProtocol>(_ someDTO: T, recordName: String) async throws { ... }
Feb ’25
Comment on How to correctly fetch data using SwiftData
If all code is in the original post then you have no place where you create your ModelContainer instance
Topic: UI Frameworks SubTopic: General Tags:
Replies
Boosts
Views
Activity
Nov ’25
Comment on @Attribute 'unique' and complex keys
That’s correct, you can’t use the unique constraint together with iCloud. I guess you need to add your own check to see if you need to do an insert or an update.
Replies
Boosts
Views
Activity
Sep ’25
Comment on
When I tested this I didn't use model(for:) since I already had access to the object and then isDeleted was set to true after the deletion. This looks like an issue with SwiftData that. you might want to file a report about but as far as real world programming goes your example code looks quite contrived and I don't see why you would want to do something like this.
Replies
Boosts
Views
Activity
May ’25
Comment on modelContext.fetch() hits assert on release builds, but not on debug builds
Hi My question had nothing to do with the assert, I just wanted to understand the code better since the non-generic version worked and now I understand it better. I don't know if you are interested in testing this but I was thinking that maybe it's the associated type that causes the issues so one alternative to get would be to use MyModelProtocol instead for the generic type func addRecord<T: MyModelProtocol>(_ someDTO: T, recordName: String) async throws { ... }
Replies
Boosts
Views
Activity
Feb ’25
Comment on SwiftData/ModelCoders.swift:1762: Fatal error: Passed nil for a non-optional keypath
A crash is exactly that, the app crashes immediately. When an error is thrown the app continues to run and can handle the error
Replies
Boosts
Views
Activity
Aug ’24