Created
March 29, 2018 23:37
-
-
Save thepost/a51174f0afd926cc6f8c41dbf091ab91 to your computer and use it in GitHub Desktop.
A small protocol to remove the need for your view controllers to use tricky #selector syntax
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
import UIKit | |
@objc protocol SelectorContext { | |
var selector: Selector { get } | |
func selectorCallback(_ sender: Any) | |
} | |
extension UIViewController: SelectorContext { | |
var selector: Selector { | |
return #selector(selectorCallback(_:)) | |
} | |
func selectorCallback(_ sender: Any) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment