Skip to content

Instantly share code, notes, and snippets.

View mstana's full-sized avatar

Marek Stana mstana

View GitHub Profile
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)