Last active
December 8, 2015 10:09
-
-
Save alexanderedge/49ffd346e25b325fde51 to your computer and use it in GitHub Desktop.
Statically-typed functions for simple gesture recognisers
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
protocol Tappable : AnyObject { | |
func handleTap(gr : UITapGestureRecognizer) | |
} | |
extension UITapGestureRecognizer { | |
convenience init(target : Tappable) { | |
self.init(target: target, action: "handleTap:") | |
} | |
} | |
protocol LongPressable : AnyObject { | |
func handleLongPress(gr : UILongPressGestureRecognizer) | |
} | |
extension UILongPressGestureRecognizer { | |
convenience init(target : LongPressable) { | |
self.init(target: target, action: "handleLongPress:") | |
} | |
} | |
protocol Pannable : AnyObject { | |
func handlePan(gr : UIPanGestureRecognizer) | |
} | |
extension UIPanPressGestureRecognizer { | |
convenience init(target : Pannable) { | |
self.init(target: target, action: "handlePan:") | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment