Last active
January 2, 2019 15:44
-
-
Save dimohamdy/fab3030c686045644a8b0c2785ab90c7 to your computer and use it in GitHub Desktop.
Generic function to exchange function
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
let swizzling: (AnyClass, Selector, Selector) -> Void = { forClass, originalSelector, swizzledSelector in | |
guard | |
let originalMethod = class_getInstanceMethod(forClass, originalSelector), | |
let swizzledMethod = class_getInstanceMethod(forClass, swizzledSelector) | |
else { return } | |
method_exchangeImplementations(originalMethod, swizzledMethod) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment