I have several methods, like below:
- (void)methodA;
- (void)methodB;
- (void)methodC;
and they are used depending on some conditions.
Now I want to dynamically use them, and I tried this:
NSString *methodName;
if(_flag == A) methodName = @"methodA";
else if (_flag == b) methodName = @"methodB";
else methodName = @"methodC";
[self performSelector:@selector(methodName)];
but it seems wrong.
So how should I use a dynamic method name for a given receiver depending on different situations?
Thanks a lot!
Use this instead: