Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. self.showAlertWithButtonClicked(clickedButton: { (clickedButton) -> Void in
  2. //check the button index by clickedButton.tag
  3.  
  4. })
  5.  
  6. class MyAlertController: UIViewController {
  7.  
  8.  
  9. typealias CompletionHandler = (_ clickedButton: UIButton) -> Void
  10. override func viewDidLoad() {
  11. super.viewDidLoad()
  12. // Do any additional setup after loading the view.
  13. }
  14.  
  15. func showAlertWithButtonClicked(clickedButton: @escaping (MultipleMethodRunningHandle)) {
  16. //Do what you want
  17.  
  18. }
  19.  
  20. func pressedCancelButton(button: UIButton) {
  21. //At this point compiler doesn't allow me to use that completionHandler globally in the class
  22. button.tag = 0
  23. clickedButton(button)
  24. }
  25. func pressedSendButton(button: UIButton) {
  26. //At this point compiler doesn't allow me to use that completionHandler globally in the class
  27. button.tag = 1
  28. clickedButton(button)
  29. }
  30. func pressedAddButton(button: UIButton) {
  31. //At this point compiler doesn't allow me to use that completionHandler globally in the class
  32. button.tag = 2
  33. clickedButton(button)
  34. }
  35.  
  36. override func didReceiveMemoryWarning() {
  37. super.didReceiveMemoryWarning()
  38. // Dispose of any resources that can be recreated.
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement