Skip to content

Instantly share code, notes, and snippets.

@OscarApeland
Created October 12, 2019 20:54
Show Gist options
  • Save OscarApeland/8eeaa0c507e44d5fad2d521fb4956454 to your computer and use it in GitHub Desktop.
Save OscarApeland/8eeaa0c507e44d5fad2d521fb4956454 to your computer and use it in GitHub Desktop.
protocol CustomSubviewDelegate: class {
func customSubview(_ customSubview: CustomSubview, didEnterText text: String)
}
class CustomSubview: UIView {
weak var delegate: CustomSubviewDelegate?
// init and setup and stuff
@objc func textFieldDidChange(_ textField: UITextField) {
delegate?.customSubview(self, didEnterText: textField.text!)
}
}
class CustomViewController {
func viewDidLoad() {
customSubview.delegate = self
}
}
extension CustomViewController: CustomSubviewDelegate {
func customSubview(_ customSubview: CustomSubview, didEnter text: String) {
print(text)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment