Created
July 2, 2017 20:37
-
-
Save mavris/dd3502c08e196d2b00264cca007af042 to your computer and use it in GitHub Desktop.
This file contains 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
BOOL isMethodExists = !class_addMethod([self class], defaultSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); | |
if (isMethodExists) { | |
method_exchangeImplementations(defaultMethod, swizzledMethod); | |
} | |
else { | |
class_replaceMethod([self class], swizzledSelector, method_getImplementation(defaultMethod), method_getTypeEncoding(defaultMethod)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment