-
-
Save hamishknight/ea961b8aa360a13b9f1cb1a886a6eaab to your computer and use it in GitHub Desktop.
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
import Foundation | |
class C { | |
@objc /*dynamic*/ func foo() { | |
print("foo") | |
} | |
@objc /*dynamic*/ func bar() { | |
print("bar") | |
} | |
} | |
let fooMethod = class_getInstanceMethod(C.self, #selector(C.foo)) | |
let barMethod = class_getInstanceMethod(C.self, #selector(C.bar)) | |
method_exchangeImplementations(fooMethod, barMethod) | |
let c = C() | |
c.foo() // foo | |
c.bar() // bar | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment