NSValueTransformer 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 NSValueTransformer, 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

+ setValueTransformer:forName:

Registers the provided value transformer with a given identifier.

+ valueTransformerForName:

Returns the value transformer identified by a given identifier.

+ valueTransformerNames

Returns an array of all the registered value transformers.

Getting Information About a Transformer

+ allowsReverseTransformation

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

+ transformedValueClass

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

Using Transformers

- transformedValue:

Returns the result of transforming a given value.

- reverseTransformedValue:

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


Named Value Transformers

The following named value transformers are defined by NSValueTransformer:


Inherits From