mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Storing an array or dict with CoreStoreObject? #180
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 @kevinrenskers on GitHub (Oct 24, 2017).
Is it possible to store an array or dict with CoreStoreObject? I noticed in another ticket that someone answered that question with one word:
Transformable.But something like this does not compile:
Same goes for storing a
[String: Any]dict, where I know all properties can be stored safely into Core Data (works great before refactoring to use CoreStoreObject). Any help would be greatly appreciated, thanks :)@JohnEstropia commented on GitHub (Oct 25, 2017):
Transformercurrently only supportsNSCoding. I've been planning to support SwiftCodabletypes as well but haven't gotten around it yet, sorry. I wanted to provide a way to specify the encoder type (e.g.JSONEncoderorPropertyListEncoder), but some parts ofTransformablemay need rethinking because encoders don't have a common protocol, so we need to pass in an instance.I'll bump this in my priority, in the meantime you can use
NSArrayandNSDictionary, which is what CoreData originally supports (through objc bridging). It might not have binary compatibility with the futureCodablethough.@kevinrenskers commented on GitHub (Oct 25, 2017):
Thanks works fine for now, thanks!
@bluepixeltech commented on GitHub (Nov 25, 2020):
How do I CoreStoreObject class field with NSArray field?
@JohnEstropia commented on GitHub (Nov 26, 2020):
@bluepixeltech I'm assuming you are using the
@Fieldtypes now, in which case you can use@Field.Codedfor codable arrays or dictionaries. See https://github.com/JohnEstropia/CoreStore#fieldcoded