I'd like to get an array of the attributes for my NSManagedObject
so I can use KVO to export them. I can create an array manually and then iterate through it, however, I'd like to get this list automatically, then iterate.
There are two steps to storing an array of a custom struct or class in Core Data. The first step is to create a Core Data entity for your custom struct or class. The second step is to add a to-many relationship in the Core Data entity where you want to store the array.
In some respects, an NSManagedObject acts like a dictionary—it's a generic container object that provides efficient storage for the properties defined by its associated NSEntityDescription instance.
When you declare a property as Transformable Core Data converts your custom data type into binary Data when it is saved to the persistent store and converts it back to your custom data type when fetched from the store. It does this through a value transformer.
An NSManagedObject has an entity associated with it. Use NSEntityDescription's -attributesByName
and -relationshipsByName
. You'll get a dictionary back from each of those methods. Just ask the dicts for their -allKeys
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With