How to swizzle UIApplication in iOS?

632 views Asked by At

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.

1

There are 1 answers

0
Ben Zotto On

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.