@implementation AppDelegate (IdentityUrlHandling) + (void)load { swizzleMethod([AppDelegate class], @selector(application:openURL:sourceApplication:annotation:), @selector(identity_application:openURL:sourceApplication:annotation:)); swizzleMethod([AppDelegate class], @selector(application:openURL:options:), @selector(indentity_application_options:openURL:options:)); } ・・・ @end ・・・ static void swizzleMethod(Class class, SEL destinationSelector, SEL sourceSelector) { Method destinationMethod = class_getInstanceMethod(class, destinationSelector); Method sourceMethod = class_getInstanceMethod(class, sourceSelector); // If the method doesn't exist, add it. If it does exist, replace it with the given implementation. if (class_addMethod(class, destinationSelector, method_getImplementation(sourceMethod), method_getTypeEncoding(sourceMethod))) { class_replaceMethod(class, destinationSelector, method_getImplementation(destinationMethod), method_getTypeEncoding(destinationMethod)); } else { method_exchangeImplementations(destinationMethod, sourceMethod); } }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。