Skip to content

Instantly share code, notes, and snippets.

@sanllier
Last active November 5, 2020 10:38
Show Gist options
  • Select an option

  • Save sanllier/c2d672f81e7dffbdec39d2d9774be475 to your computer and use it in GitHub Desktop.

Select an option

Save sanllier/c2d672f81e7dffbdec39d2d9774be475 to your computer and use it in GitHub Desktop.
let objcSelector = Selector("veryUsefulMethod")
typealias CFunction = @convention(c) (AnyObject, Selector) -> Void
let impl = class_getMethodImplementation(type(of: self).self, objcSelector)
let callableImpl = unsafeBitCast(impl, to: CFunction.self)
callableImpl(self, objcSelector)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment