Created
November 10, 2017 16:26
-
-
Save yabenatti/438aaf14ceff2320745e736c25cfdc9b to your computer and use it in GitHub Desktop.
DelegateTutorialFirstViewController
This file contains 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
import UIKit | |
class FirstViewController: UIViewController, SecondViewControllerProtocol { | |
// MARK: - Navigation | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
if segue.identifier == "FirstToSecondSegue" { | |
if let vc = segue.destination as? SecondViewControllerProtocol { | |
vc.delegate = self | |
} | |
} | |
} | |
//MARK: - SecondViewControllerDelegate | |
func didDoSomethingOnSecondViewController(message: String) { | |
let alert = UIAlertController(title: "Delegate", message: "\(message)", preferredStyle: .alert) | |
let action = UIAlertAction(title: "OK", style: .cancel, handler: nil); | |
alert.addAction(action) | |
self.present(alert, animated: true, completion: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment