Created
November 25, 2014 10:35
-
-
Save edewit/03199e68aeb094b8a27a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AppDelegate+url.h" | |
#import "AeroGearHttp.h" | |
#import <objc/runtime.h> | |
@implementation AppDelegate (url) | |
// its dangerous to override a method from within a category. | |
// Instead we will use method swizzling. we set this up in the load call. | |
+ (void)load | |
{ | |
Method original, swizzled; | |
original = class_getInstanceMethod(self, @selector(application:openURL:sourceApplication:annotation:)); | |
swizzled = class_getInstanceMethod(self, @selector(swizzled_application:openURL:sourceApplication:annotation:)); | |
method_exchangeImplementations(original, swizzled); | |
} | |
- (BOOL)swizzled_application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation | |
{ | |
NSNotification *notification = [NSNotification notificationWithName:@"AGAppLaunchedWithURLNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:url forKey:UIApplicationLaunchOptionsURLKey]]; | |
[[NSNotificationCenter defaultCenter] postNotification:notification]; | |
return [self swizzled_application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would think this would be the equivalent in swift, but it seems I'm wrong
Error: can not use init