Permalink
Browse files

Treat zero-length strings as nil, failing gracefully for inconsistent…

… APIs
  • Loading branch information...
1 parent 1f9bb9e commit 6aeb793f732fc14cb5bf225fa7e79a5ec69210ba @myell0w committed Mar 20, 2013
Showing with 3 additions and 0 deletions.
  1. +3 −0 Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.m
@@ -51,6 +51,9 @@ + (NSValueTransformer *)mtl_JSONDictionaryTransformerWithModelClass:(Class)model
return [MTLValueTransformer
reversibleTransformerWithForwardBlock:^ id (NSDictionary *JSONDictionary) {
if (JSONDictionary == nil) return nil;
+ if ([JSONDictionary isKindOfClass:[NSString class]] && ((NSString *)JSONDictionary).length == 0) {
+ return nil;
+ }
NSAssert([JSONDictionary isKindOfClass:NSDictionary.class], @"Expected a dictionary, got: %@", JSONDictionary);

0 comments on commit 6aeb793

Please sign in to comment.