Permalink
Browse files

Remove use of `performSelector`

  • Loading branch information...
1 parent d8fe323 commit 961b3099ebb8a970b72f6c788e47f37036230655 @billinghamj billinghamj committed Oct 7, 2016
Showing with 11 additions and 24 deletions.
  1. +11 −24 JSONModel/JSONModel/JSONModel.m
@@ -449,30 +449,22 @@ -(BOOL)__importDictionary:(NSDictionary*)dict withKeyMapper:(JSONKeyMapper*)keyM
//check if there's a transformer with that name
if (foundCustomTransformer) {
+ IMP imp = [valueTransformer methodForSelector:selector];
+ id (*func)(id, SEL, id) = (void *)imp;
+ jsonValue = func(valueTransformer, selector, jsonValue);
- //it's OK, believe me...
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- //transform the value
- jsonValue = [valueTransformer performSelector:selector withObject:jsonValue];
-#pragma clang diagnostic pop
-
- if (![jsonValue isEqual:[self valueForKey:property.name]]) {
- [self setValue:jsonValue forKey: property.name];
- }
-
+ if (![jsonValue isEqual:[self valueForKey:property.name]])
+ [self setValue:jsonValue forKey:property.name];
} else {
NSString* msg = [NSString stringWithFormat:@"%@ type not supported for %@.%@", property.type, [self class], property.name];
JSONModelError* dataErr = [JSONModelError errorInvalidDataWithTypeMismatch:msg];
*err = [dataErr errorByPrependingKeyPathComponent:property.name];
return NO;
}
-
} else {
// 3.4) handle "all other" cases (if any)
- if (![jsonValue isEqual:[self valueForKey:property.name]]) {
- [self setValue:jsonValue forKey: property.name];
- }
+ if (![jsonValue isEqual:[self valueForKey:property.name]])
+ [self setValue:jsonValue forKey:property.name];
}
}
}
@@ -1017,17 +1009,12 @@ -(NSDictionary*)toDictionaryWithKeys:(NSArray*)propertyNames
//check if there's a transformer declared
if (foundCustomTransformer) {
+ IMP imp = [valueTransformer methodForSelector:selector];
+ id (*func)(id, SEL, id) = (void *)imp;
+ value = func(valueTransformer, selector, value);
- //it's OK, believe me...
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- value = [valueTransformer performSelector:selector withObject:value];
-#pragma clang diagnostic pop
-
- [tempDictionary setValue:value forKeyPath: keyPath];
-
+ [tempDictionary setValue:value forKeyPath:keyPath];
} else {
-
//in this case most probably a custom property was defined in a model
//but no default reverse transformer for it
@throw [NSException exceptionWithName:@"Value transformer not found"

0 comments on commit 961b309

Please sign in to comment.