Last active
March 22, 2018 18:19
-
-
Save sanllier/386349d81e8b2c0aaf00f0e70f76bce3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@objc func veryUsefulMethod() { | |
guard let superclass = superclass else { return } | |
let objcSelector = Selector("veryUsefulMethod") | |
typealias CFunction = @convention(c) (AnyObject, Selector) -> Void | |
let impl = class_getMethodImplementation(superclass, 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