Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between transformable and binary data

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.

like image 505
S.J Avatar asked Jan 10 '13 11:01

S.J


1 Answers

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.

like image 50
Tom Harrington Avatar answered Oct 05 '22 18:10

Tom Harrington