Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DelegateTutorialFirstViewController
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
You can’t perform that action at this time.