简体   繁体   中英

How to swizzle UIApplication in iOS?

I need to Swizzle UIApplication class methods especially " application:handleOpenURL: ". I have added a category class of UIApplication. I have exchanged my own method with the original method but, it never triggered. The Swizzle class called very first time of app launch but, the swizzle method never triggered. I have attached the code for your reference.

- (BOOL) xxx_application: (UIApplication *) application handleOpenURL: (NSURL *) url {
    NSLog(@"\n\n Swizzle handle open url..");
    [self xxx_application:application handleOpenURL:url];
    NSLog(@"URL: %@", url);
    return YES; }

Can anyone please save my day? I tried of using some private library like "RSSwizzle" but, no help.

You don't need to swizzle this method, and it doesn't exist on UIApplication anyway. It is a method that is part of UIApplication's delegate protocol, meaning that (typically) your "app delegate" class should simply implement the method to have it called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM