Created
October 12, 2019 20:54
-
-
Save OscarApeland/8eeaa0c507e44d5fad2d521fb4956454 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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