Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to supress a "Class may not respond to '-method' warning with variable method name?

Tags:

objective-c

How can I prevent this warning with a variable selector name?

NSString *methodName;

SEL method = NSSelectorFromString(methodName);

if ([self respondsToSelector:method]) {

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

}
like image 971
Joris Weimar Avatar asked Sep 01 '11 17:09

Joris Weimar


1 Answers

Use

[self performSelector:method];

Instead of

[self method];

And

[self performSelector:method withObject:dict];

Instead of

[self method:dict];
like image 179
sidyll Avatar answered Nov 15 '22 09:11

sidyll