Post

Replies

Boosts

Views

Activity

Reply to iOS 18.1 and SeiftData
Thank you all for posting this and the solution. This is literally the only resource about this on the internet. It helped me with a resolution. My app was working fine for iOS 17, but for iOS 18 would silently fail with the mentioned error b/c I didn't explicitly define the relationships and set the corresponding objects before insertion. I really can't believe Apple just made breaking changes to SwiftData, a supposedly stable framework, without any communication or documentation thereof. Very unprofessional. Never again will I be an early adopter of any of Apple's developer technologies.
Oct ’24
Reply to SwiftData Array in random order?
I came up with the most elegant workaround I could and posted it as a small sample app here: https://github.com/hekuli/swiftdata-test The gist is that I make the model's array private, and have a corresponding public computed property that always sorts the array when accessed. I also use a Factory pattern for higher-level orchestration to manipulate the models b/c I encountered too many SwiftData crashes if model operations were not performed in exact order it likes. I'm still not sure if this is the best approach, so I'd love to hear any suggestions on how it could be improved.
Feb ’24