你使用过Objective-C的运行时编程(Runtime Pr

2016-02-25  本文已影响142人  丶逐渐

Objecitve-C的重要特性是Runtime(运行时),在#import  下能看到相关的方法,用过objc_getClass()和class_copyMethodList()获取过私有API;使用

```objective-c

Method method1 = class_getInstanceMethod(cls, sel1);

Method method2 = class_getInstanceMethod(cls, sel2);

method_exchangeImplementations(method1, method2);

代码交换两个方法,在写unit test时使用到。

上一篇 下一篇

猜你喜欢

热点阅读