This is my code from view-a:
/
protocol DetailViewControllerDelegate: class {
func updateTipData(foodnDrinkData: String?, taxData: String?,
tipData: String?, splitData: String?)
}
weak var delegate: DetailViewControllerDelegate?
func updateTipTextFields(){ /
print("\nIN Detail-VC > updateTipTextFields().................................................\n")
delegate?.updateTipData(foodnDrinkData: detailFoodnDrinkTextField?.text,
taxData: detailTaxTextField?.text,
tipData: detailTipPercentTextField?.text,
splitData: detailSplitTextField?.text)
print("\n EXIT Detail-VC > updateTipTextFields().................................................\n")
}
The updateTipData() method is triggered in textFieldDidEndEditing(). All of the above code resides in the DetailViewController class. (view-a in the graphic)
The following code is in the TipperoniViewController: (view-A in the graphic)
class TipperoniViewController: UIViewController, UITextFieldDelegate, DetailViewControllerDelegate {
So now the TipperoniViewController class conforms to the DetailViewControllerDelegate protocol.
And here is the protocol delegate pattern method:
func updateTipData(foodnDrinkData: String?, taxData: String?,
tipData: String?, splitData: String?) {
print("\nIN Tip-VC > updateTipData(...) .................................................YES! NO! \n")
foodnDrinkTextField.text = foodnDrinkData
taxTextField.text = taxData
tipTextField.text = tipData
splitTextField.text = splitData
saveUserData()
print("\n EXIT Tip-VC > updateTipData(...) ....................................... YES! NO!\n")
}
As noted earlier, this code works perfectly. What follows is the code that does not work.
Here is view-b's code:
protocol SetTipPrefViewControllerDelegate: class {
func updateTipPrefValue(tipData: String?)
}
class SetTipPrefViewController: UIViewController, UITextFieldDelegate {
weak var delegate: SetTipPrefViewControllerDelegate?
func updateUserTipPrefValue(){
print("\nIN > SetTipPrefViewController > updateUserTipPrefValue() ................ 5-6-7 ... ?-?-?\n")
delegate?.updateTipPrefValue(tipData: tipPrefTextField?.text)
}
The latter method is triggered in the textFieldDidEndEditing() method.
Here is view-a's code:
class DetailViewController: UIViewController, UITextFieldDelegate, SetTipPrefViewControllerDelegate {
And here is the protocol pattern method triggered in view-a:
func updateTipPrefValue(tipData: String?) {
print("\nIN > DetailViewController > updateTipPrefValue(...) .........................3-3-3-3-3-3-3\n")
detailTipPercentTextField.text = tipData
}
I
safdaI
I'm stuck here and cannot add non-code text. Thanks for your help.