Skip to content

Instantly share code, notes, and snippets.

@mayooresan
Last active July 18, 2017 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayooresan/339d0ff0314f13bc0cbaed41cc4b90d8 to your computer and use it in GitHub Desktop.
Save mayooresan/339d0ff0314f13bc0cbaed41cc4b90d8 to your computer and use it in GitHub Desktop.
import UIKit
protocol SpyDelegate {
func didFindWeaponOfMassDestruction(found : Bool)
}
class EnemyBaseVC: UIViewController {
let hasWeaponOfMassDescrtruction : Bool = true
var delegate : SpyDelegate?
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func sendingMessage(_ sender: Any) {
// if delegate is nil then the app will crash
// so you must do this check
if delegate != nil {
delegate?.didFindWeaponOfMassDestruction(found: hasWeaponOfMassDescrtruction)
//dismiss the modal
dismiss(animated: true, completion: nil)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment