I recently start working on core data, please can any one tell me whats the difference between transformable and binary data. I need to store myClassObject in core data. I have created the attribute and defined its type as binary data, but at the time of storing I am getting error.
With a binary attribute, you read and write instances of NSData
directly.
With a transformable attribute, you read and write instances of any class that can be converted to and from NSData
. The actual data storage is the same as with a binary attribute, but Core Data uses an NSValueTransformer
to convert to/from NSData
when necessary.
For example, say your managed object has an image attribute where it would be convenient to read and write UIImage
directly. Except, UIImage
can't be saved in Core Data. But UIImage
can be converted to and from NSData
. So, if you used a transformable attribute you could read and write UIImage
while still keeping NSData
in the data store.
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