jackyshan

导航

 

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)];
posted on 2016-05-20 17:19  jackyshan  阅读(134)  评论(0编辑  收藏  举报