Post

Replies

Boosts

Views

Activity

@ObservationIgnored weak var - must be initialised?
I understand that @Observable currently requires all properties to be initialised. However I am surprised that opting out of observation does not work: @Observable class Assessment { var name = "" var processes: [Process] = [] } @Observable class Process { var name = "" @ObservationIgnored weak var parent: Assessment? } The error message is Return from initializer without initializing all stored properties from the Process class. Any suggestions?
0
1
1k
Jul ’23
JSON encoding of AttributedString with custom attributes
I have implemented custom attributes for an AttributedString and successfully converted to NSAttributedString and used in NSTextView with custom coloring and background, works nicely! What does not work is encoding the AttributedString to JSON. The custom attributes are not coded. I use a plain JSON encode like this: let data = JSONEncoder().encode(object) I assume some option is needed for the encoder to deal with the custom attributes (like when converting to NSAttributedString), but I have not been able to find any documentation on how to do this. Any suggestions?
1
0
2.4k
Sep ’21