如何通过变量方法名称来抑制"类可能无法响应'-method'警告?

Jor*_*mar 5 objective-c

如何使用变量选择器名称阻止此警告?

NSString *methodName;

SEL method = NSSelectorFromString(methodName);

if ([self respondsToSelector:method]) {

    if ([methodName hasSuffix:@":"])
        [self method:dict];
    else
        [self method];

}
Run Code Online (Sandbox Code Playgroud)

sid*_*yll 9

使用

[self performSelector:method];
Run Code Online (Sandbox Code Playgroud)

代替

[self method];
Run Code Online (Sandbox Code Playgroud)

[self performSelector:method withObject:dict];
Run Code Online (Sandbox Code Playgroud)

代替

[self method:dict];
Run Code Online (Sandbox Code Playgroud)