Skip to content

Instantly share code, notes, and snippets.

@morizotter
Last active August 29, 2015 14:14
Show Gist options
  • Save morizotter/bf6a188600d3b9ed9c17 to your computer and use it in GitHub Desktop.
Save morizotter/bf6a188600d3b9ed9c17 to your computer and use it in GitHub Desktop.
func swizzle() {
var dict = ["This is Key.": "This is value."] as NSDictionary
var method: Method = class_getInstanceMethod(object_getClass(dict), "description")
var swizzledMethod: Method = class_getInstanceMethod(object_getClass(dict), "myDescription")
method_exchangeImplementations(method, swizzledMethod)
println(dict.description)
}
MY DESCRIPTION!!
{
"This is Key." = "This is value.";
}
extension NSDictionary {
func myDescription() -> String {
println("MY DESCRIPTION!!")
return myDescription()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment