Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
extension UIControl.Event: Hashable{
public var hashValue: Int{
return Int(self.rawValue)
static func == (lhs: UIControl.Event, rhs: UIControl.Event) -> Bool{
return lhs.rawValue == rhs.rawValue
class Button: UIButton{
private class Actuator{
let action: ()->Void
init(action: @escaping ()->Void){
self.action = action
@objc func performAction(){
private var actions = [UIControl.Event:Actuator]()
func on(_ event: UIControl.Event, perform action: @escaping ()->Void){
actions[event] = Actuator(action: action)
addTarget(actions[event], action: #selector(Actuator.performAction), for: event)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment