Skip to content

Instantly share code, notes, and snippets.

@chriswebb09
Created May 11, 2017 09:13
Show Gist options
  • Save chriswebb09/a1e800658f115414ce292639b9806dd1 to your computer and use it in GitHub Desktop.
Save chriswebb09/a1e800658f115414ce292639b9806dd1 to your computer and use it in GitHub Desktop.
class MainView: UIView {
@IBOutlet private weak var myTextfield: UITextField!
@IBOutlet private weak var myButton: UIButton!
weak var delegate: MainViewDelegate?
override func layoutSubviews() {
super.layoutSubviews()
myButton.addTarget(self, action: #selector(buttonTap), for: .touchUpInside)
}
func buttonTap() {
guard let searchText = myTextfield.text else { return }
delegate?.searchButtonTappedWithTerm(with: searchText)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment