I can’t figure out why the code in if statement is not executed
NSString *str = @"capitalizedString";
NSString *name = @"chris";
SEL selector = NSSelectorFromString(str);
if([NSString respondsToSelector:selector]) {
NSLog(@"%@", [name performSelector:selector]);
}
EDIT //
This code works fine
NSString *color = @"blueColor";
SEL selector = NSSelectorFromString(color);
if([UIColor respondsToSelector:selector])
{
myColor = [UIColor performSelector:selector];
}
capitalizedStringis not a static method. So you can not use NSString directly. Instead you should use the object of it. In your case it could ne name or str.