Skip to content

Instantly share code, notes, and snippets.

@thepost
Created March 29, 2018 23:37
Show Gist options
  • Save thepost/a51174f0afd926cc6f8c41dbf091ab91 to your computer and use it in GitHub Desktop.
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
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