Skip to content

Instantly share code, notes, and snippets.

@dimohamdy
Last active January 2, 2019 15:44
Show Gist options
  • Save dimohamdy/fab3030c686045644a8b0c2785ab90c7 to your computer and use it in GitHub Desktop.
Save dimohamdy/fab3030c686045644a8b0c2785ab90c7 to your computer and use it in GitHub Desktop.
Generic function to exchange function
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