新建工程,注入 Framework后,注入簡(jiǎn)單測(cè)試代碼,利用 Runtime 特性交換方法
#import <objc/message.h>
+ (void)load
{
// 傳入 -id- 類(lèi)型
// object_getClass(id _Nullable obj)
// 傳入-字符串- 類(lèi)型
// objc_getClass(const char * _Nonnull name)
// WCAccountLoginControlLogic
// onFirstViewRegester
// 獲取WC的方法
Method old_Method = class_getInstanceMethod(objc_getClass("WCAccountLoginControlLogic"), @selector(onFirstViewRegester));
Method new_Mehod = class_getInstanceMethod(self, @selector(test1));
method_exchangeImplementations(old_Method, new_Mehod);
NSLog(@"加載完成--??????????????????????!!!");
}
- (void)test1
{
NSLog(@"???????????????????????。?!\n 系統(tǒng)檢測(cè)到異常!?。。。〔荒茏?cè)?。?!");
}