Dynamically invoke a class method in Objective C
代码
#import <Foundation/Foundation.h>
#import "A.h"
@implementation A
- (NSString *)description
{
return [NSString stringWithString: @"A"];
}
+ (NSString *)action
{
return [NSString stringWithString:@"A::action"];
}
@end
方法执行
A *a = [[A class] performSelector:@selector(action)];