Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
38 views

How to make multiple existing SwitftData models to conform to Codable by inheriting from base class?

The following is my attempt (with ChatGPT 3.5's help) to implement a base class A: Codable with required init and func encode where I am trying to use reflection to findout B.property1 and C.property2 ...
alienfromouterspace's user avatar
1 vote
0 answers
149 views

How can one persist an AttributedString within the SwiftData framework?

The problem of how to persist AttributedString data within the SwiftData framework isn't, as far as I can tell, specifically addressed anywhere. And since (custom) AttributedStrings address several ...
Optimalist's user avatar
0 votes
3 answers
248 views

Unable to get SwiftData to store/retrieve CGPoint, CGSize, CGRect

I'm trying to get SwiftData to store Core Graphics base structures like CGSize, CGRect, CGPoint, but it doesn't work. I suppose CGVector and CGAffineTransform could be added to the list, but I haven't ...
HighFive's user avatar
0 votes
0 answers
310 views

SwiftData Model Inheriting from Codable Class

I have a backend written in swift (hosted on GCP Cloud Run, aka linux so no access to Apple-specific frameworks). I have a regular codable class: open class MyClass: Codable, Identifiable { var id:...
Chris Schlitt's user avatar
0 votes
2 answers
652 views

SwiftData with Codable

I'm attempting to integrate SwiftData into my networking model to incorporate local persistence. In order to achieve this, I need to ensure that my Codable model conforms to SwiftData. However, I ...
ali.ios's user avatar
  • 51
4 votes
1 answer
819 views

SwiftData crashes when setting optional String of Codable property

I've run into an issue where setting a property on a SwiftData object to a Codable struct with an optional String crashes the app. For example, if I have the following model object and struct : @Model ...
Michael Berk's user avatar