Reputation: 3071
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.
Upvotes: 18
Views: 7790
Reputation: 70936
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.
Upvotes: 30