#import <objc/runtime.h>
#import <objc/message.h>
需要导入运行时头文件和消息发送文件
- (void)runTests
{
unsigned int count;
Method *methods = class_copyMethodList([self
class], &count);
for (int i =
0; i < count; i++)
{
Method method = methods[i];
SEL selector = method_getName(method);
NSString *name = NSStringFromSelector(selector);
// if ([name hasPrefix:@"test"])
NSLog(@"方法
名字 ==== %@",name);
if (name)
{
//avoid arc warning by using c runtime
// objc_msgSend(self, selector);
}
NSLog(@"Test '%@' completed successfuly", [name
substringFromIndex:4]);
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。