我想在 iOS 中挂钩委托(协议)方法,谁能告诉我怎么做?
比如钩子法applicationDidFinishLaunching:
我这样做,但它不工作......
extern IMP original_UIApplication_applicationDidFinishLaunching;
extern void replaced_UIApplication_applicationDidFinishLaunching(UIApplication<UIApplicationDelegate> * self, SEL cmd, UIApplication* application);
MSHookMessageEx(objc_getMetaClass("UIApplication"),
@selector(applicationDidFinishLaunching:),
(IMP)replaced_UIApplication_applicationDidFinishLaunching,
(IMP *)&original_UIApplication_applicationDidFinishLaunching);