It's not enough to make the attribute transformable, you also need to arrange for the transformation to happen. You can't just tell Core Data to transform any old object and expect it to know what to do. You have a couple of options:
Don't tell Core Data how to transform the data. In this case, Core Data will attempt to call
encodeWithCoder:
on your object to convert it toNSData
. That's why you get the error that mentions this method-- it's trying to call the method on your class, but that method doesn't exist. In this case your class must conform toNSCoding
for the transformation to occur.Tell Core Data how to transform the data. In this case you create a subclass of
NSValueTransformer
that performs the transformation. You configure this on the attribute, either in the Core Data model editor or in code. In this case, you must have a custom transformer class that knows how to perform the transformation.