NSValue​Transformer is an abstract class that is used by the Cocoa Bindings technology to transform values from one representation to another.


An application creates a subclass of NSValue​Transformer, overriding the necessary methods to provide the required custom transformation.


A relatively trivial value transformer takes an object of type id and returns a string based on the object’€™s class type. This transformer is not reversible as it’s probably unreasonable to transform a class name into an object. The value transformer class you write to accomplish this simple task could look like:

@interface ClassNameTransformer: NSValueTransformer {}
@implementation ClassNameTransformer
+ (Class)transformedValueClass { return [NSString class]; }
+ (BOOL)allowsReverseTransformation { return NO; }
- (id)transformedValue:(id)value {
    return (value == nil) ? nil : NSStringFromClass([value class]);


Using Name-based Registry

+ set​Value​Transformer:​​for​Name:​​

Registers the provided value transformer with a given identifier.

+ value​Transformer​For​Name:​​

Returns the value transformer identified by a given identifier.

+ value​Transformer​Names

Returns an array of all the registered value transformers.

Getting Information About a Transformer

+ allows​Reverse​Transformation

Returns a Boolean value that indicates whether the receiver can reverse a transformation.

+ transformed​Value​Class

Returns the class of the value returned by the receiver for a forward transformation.

Using Transformers

- transformed​Value:​​

Returns the result of transforming a given value.

- reverse​Transformed​Value:​​

Returns the result of the reverse transformation of a given value.


Named Value Transformers

The following named value transformers are defined by NSValue​Transformer:


Inherits From