Skip to content

Instantly share code, notes, and snippets.

@jsorge
Last active March 15, 2016 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsorge/e5237717ecf1b18cab66 to your computer and use it in GitHub Desktop.
Save jsorge/e5237717ecf1b18cab66 to your computer and use it in GitHub Desktop.
import UIKit
protocol ResponderTest: class {
var name: String { get }
func printName() -> String
}
extension ResponderTest where Self: NSObject {
func printName() -> String {
return name
}
}
class ResponderObject: NSObject, ResponderTest {
let name = "Jared"
}
let testObject = ResponderObject()
print(testObject.printName())
let sel = Selector("printName")
let responds = testObject.respondsToSelector(sel)
if responds {
print("It works! 🎉")
}
else {
print("It doesn't 💀🔥")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment