rajdeep / proton

Purely native and extensible rich text editor for iOS and macOS Catalyst apps
Other
1.28k stars 82 forks source link

Saving NSAttributedString to CoreData crashes #154

Closed bryan1anderson closed 2 years ago

bryan1anderson commented 2 years ago

Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={NSUnderlyingError=0x282e77330 {Error Domain=NSCocoaErrorDomain Code=4866 "The data couldn’t be written because it isn’t in the correct format." UserInfo={NSUnderlyingError=0x282e772a0 {Error Domain=NSCocoaErrorDomain Code=4864 "This decoder will only decode classes that adopt NSSecureCoding. Class 'PREditorContentName' does not adopt it." UserInfo={NSDebugDescription=This decoder will only decode classes that adopt NSSecureCoding. Class 'PREditorContentName' does not adopt it.}}}}}

PREditorContentName assuming is the issue? Do you recommend something else for CoreData, like saving the string as data?

rajdeep commented 2 years ago

@bryan1anderson, your assumption is correct. This is a deliberate design decision. For encoding/decoding, you should be able to use the rawValue which is a string. For reference, please checkout example Encoder/Decoder in the ExampleApp.