What can I do with the Transformable type in Core Data on iPhone?

Here is this Transformable data type for attributes. What is this for? Are there any good examples?

I would like to play with this. So after searching I came across this: NSValueTransformer. Something seems to be needed for this.

So how do I start with this? For example, if I wanted to save a UIColor object, would I make a transformer for this?

What exactly is this transformation? NSData? And should the object that I pass to the transformer follow any protocol?

+46
iphone core-data
Jun 10 '10 at
source share
1 answer

Convertible attributes are useful for storing non-standard object types in Core Data. For example, I provide code in this answer that allows you to store UIImages as an attribute in Core Data. Image data is converted to and from an instance of NSData, which contains a representation of a PNG image. All this is handled transparently for you by a custom NSValueTransformer.

You can also encrypt individual attributes in your Core Data model, as I describe here . Using a transformable attribute to do this makes this trivial code.

+70
Jun 15 '10 at 20:51
source share



All Articles