An abstract class used 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.

Example Usage

A relatively trivial value transformer takes an object and returns a string based on the object’€™s class type. This transformer is not reversible because it doesn't make sense to transform a class name into an object. The implementation for such a value transformer could be the following:

@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.

Transforming Values

- transformedValue:

Returns the result of transforming a given value.

- reverseTransformedValue:

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


Named Value Transformers

Named value transformers defined by NSValueTransformer.


Inherits From