Failing gracefully for inconsistent APIs #82

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+3 −0
Diff settings

Always

Just for now

@@ -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);