Permalink
Browse files

Updated documentation.

  • Loading branch information...
1 parent f70e670 commit 33b6d894dac02e52b8dedf955610ccdfef550b5c @paulyoung paulyoung committed Apr 17, 2014
Showing with 12 additions and 7 deletions.
  1. +12 −7 Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.h
@@ -47,21 +47,26 @@ extern NSString * const MTLBooleanValueTransformerName;
// A reversible value transformer to transform between the keys and objects of a
// dictionary.
//
-// dictionary - The dictionary whose keys and values we should transform between.
-//
-// defaultValue - The result of mapping, in case when key not found in dictinoary.
-// This is helpful for non object property types.
+// dictionary - The dictionary whose keys and values should be
+// transformed between. This argument must not be nil.
+// defaultValue - The result to fall back to, in case no key matching the
+// input value was found during a forward transformation.
+// reverseDefaultValue - The result to fall back to, in case no value matching
+// the input value was found during a reverse
+// transformation.
//
// Can for example be used for transforming between enum values and their string
// representation.
//
// NSValueTransformer *valueTransformer = [NSValueTransformer mtl_valueMappingTransformerWithDictionary:@{
// @"foo": @(EnumDataTypeFoo),
// @"bar": @(EnumDataTypeBar),
-// } defaultValue: @(EnumDataTypeUndefined)];
+// } defaultValue: @(EnumDataTypeUndefined) reverseDefaultValue: @"undefined"];
//
-// Returns a transformer which will map from keys to objects for forward
-// transformations, and from objects to keys for reverse transformations.
+// Returns a transformer that will map from keys to values in dictionary
+// for forward transformation, and from values to keys for reverse
+// transformations. If no matching key or value can be found, the respective
+// default value is returned.
+ (NSValueTransformer *)mtl_valueMappingTransformerWithDictionary:(NSDictionary *)dictionary defaultValue:(id)defaultValue reverseDefaultValue:(id)reverseDefaultValue;
// Returns a value transformer created by calling

0 comments on commit 33b6d89

Please sign in to comment.