iOS 获取一个类的所有方法
2013-07-27 09:47
267 查看
#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]);
}
}
#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]);
}
}
相关文章推荐
- iOS 获取一个类的所有方法
- iOS 获取一个类的所有方法
- iOS 获取一个类的所有方法
- 利用反射获取一个类中的所有方法和该方法的参数
- PHP基于反射获取一个类中所有的方法
- 获取一个类的所有属性、方法的名字
- ios开发 获取一个视图的子视图的方法
- ios开发 获取一个视图的子视图的方法
- 请教:在一个在方法段的异常处理里面,如何获取当前方法输入的所有参数值。
- 获取一个类的所有属性、方法的名字
- 在Oracle中,快速获取一个部门以及它下面所有的子部门的方法。
- iOS - 通过runtime获取某个类中所有的变量和方法
- java进阶之反射:反射基础之如何获取一个类以及如何获取这个类的所有属性和方法(2)
- 使用反射获取一个类的所有方法和字段
- Java反射获取一个类的所有get方法
- iOS获取一个方法的执行时间
- iOS获取一个方法的执行时间
- IOS 获取父类的所有子类 全局替换类方法
- ios-day11-01(UIWindow的常用方法。makeKeyWindow、makeKeyAndVisible、获取当前应用的主窗口和所有窗口)
- 获取一个类的所有指定方法