performSelector may cause a leak because its selector is unknown
代码如下:
当target不清晰的情况下会出现 “PerformSelector may cause a leak because its selector is unknown” 警告
NSObject *target = parameters[@"target"];
NSString *selectorString = parameters[@"selector"];
[target performSelector:NSSelectorFromString(selectorString) withObject:nil];
可以用以下代码代替,消除警告
SEL selector = NSSelectorFromString(selectorString);
IMP imp = [target methodForSelector:selector];
void (*func)(id, SEL ,NSDictionary *json) = (void *)imp;
func(target ,selector ,@{});