I\'m trying to put entities in a Core Data store that each have non-standard data types - one is an NSDocument and the other is an NSURL. I get that within the .xcdatamodeld I n
The "where" is just anywhere in your project. Anywhere that ensures that your NSValueTransformer
subclass will exist at run time. Implement the NSValueTransformer
subclass, and enter the class name in the Core Data model as the value transformer.
However there is a default transformer. Any class that adopts the NSCoding
protocol can be automatically transformed by Core Data. In that case you mark the attribute as transformable but don't include a class name. This includes NSURL
, so you don't need to transform that or convert it to a string.
For your NSDocument
subclass then, you have the option of either implementing NSCoding
in the class or of implementing an NSValueTransformer
subclass for the document type.