Created
July 31, 2019 08:35
-
-
Save MadeBugs/6d7434bcc45b5143bdd4d7dcf972ec0b to your computer and use it in GitHub Desktop.
swizzling - swift
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
class Test { | |
dynamic func foo() { | |
print("bar") | |
} | |
} | |
extension Test { | |
@_dynamicReplacement(for: foo()) | |
func foo_new() { | |
print("bar new") | |
} | |
} | |
Test().foo() // bar new | |
//亲测可用。swift-version: 5.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment