Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated documentation.

  • Loading branch information...
commit 33b6d894dac02e52b8dedf955610ccdfef550b5c 1 parent f70e670
Paul Young paulyoung authored
Showing with 12 additions and 7 deletions.
  1. +12 −7 Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.h
19 Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.h
View
@@ -47,10 +47,13 @@ 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.
@@ -58,10 +61,12 @@ extern NSString * const MTLBooleanValueTransformerName;
// 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
Please sign in to comment.
Something went wrong with that request. Please try again.