mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 07:33:28 +01:00
Is it possible to store the array safely? #377
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @noppefoxwolf on GitHub (Oct 23, 2021).
I made a FieldCoderType because I want to save an array of NSCoding.
Is the following implementation safe?
I want to receive feedbacks about this. (I'm a beginner for CoreData.)
@JohnEstropia commented on GitHub (Oct 23, 2021):
No need to implement your own. CoreStore implements
FieldCoders.DefaultNSSecureCodingandFieldCoders.DefaultNSCodingforNSArrays, or you can useFieldCoders.Jsondirectly for swiftArrays:@noppefoxwolf commented on GitHub (Oct 24, 2021):
DefaultNSSecureCoding looks not supports typed array.
How to serialize to element that cannot encode json value?
@JohnEstropia commented on GitHub (Oct 24, 2021):
Your original code used KeyedArchiver and KeyedUnarchiver, which
DefaultNSSecureCodinguses internally so your code wouldn't work either ifDefaultNSSecureCodingdoesn't. You need to haveCodabletypes to use the built-in coders, otherwise you have to create your own way to convert to and fromDatawithout using KeyedArchiver/Unarchiver.