Skip to content

Instantly share code, notes, and snippets.

@jasdev
Created March 23, 2016 00:24
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 jasdev/3338cda9d6c799323abe to your computer and use it in GitHub Desktop.
Save jasdev/3338cda9d6c799323abe to your computer and use it in GitHub Desktop.
final class SampleViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(type: .System)
// ...
button.addTarget(self, action: #selector(SampleViewController.buttonTapped(_:)), forControlEvents: .TouchUpInside)
view.addSubview(button)
}
/**
Handle .TouchUpInside event on the button in SampleViewController.
This is a method associated with an action selector, not meant to be called externally.
- parameter button: The button that was tapped
*/
func buttonTapped(button: UIButton) {
print("Selector method called!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment