title: Customise alert view with multiple buttons
body: <p>I am designing a customised generic alert view which is shown below:</p>
  
  <p><strong>Alert view Screen Shot</strong></p>
  
  <p><img src="https://i.stack.imgur.com/7xmqe.png" alt="Screen Shot"></p>
  
  <p>However the 2 buttons in this view always perform same action. </p>
  
  <p><strong>It always perform the second line of code below for both buttons.</strong></p>
  
  <pre><code>optionAlertVC.btn_ok.actionHandle(controlEvents: .touchUpInside, ForAction: ok)
  optionAlertVC.btn_cancel.actionHandle(controlEvents: .touchUpInside, ForAction: cancel)
  </code></pre>
  
  <p><strong>Show some code for helping me to resolve this issue.</strong></p>
  
  <p><strong>ViewController:</strong></p>
  
  <pre><code>func logout() {
      AlertManager.shared.showAlertWithTwoOptions(viewController: self, message: "Confirm to logout?", okTitle: "Log out", dismissTitle: "Cancel", ok: {
          self.gotoLogin()
      }, cancel: {
          //nothing to do
      }, title: "Logout")
  }
  </code></pre>
  
  <p><strong>AlertManager:</strong></p>
  
  <pre><code>typealias ok = () -&gt; Void
  typealias cancel = () -&gt; Void
  func showAlertWithTwoOptions(viewController: UIViewController, message: String, okTitle: String, dismissTitle:String, ok: @escaping ok , cancel: @escaping cancel, title:String? = nil) {
      guard let optionAlertVC = Bundle.main.loadNibNamed("AlertView", owner: nil, options: nil)?[1] as? OptionAlertVC else {
          print("error in loading error alert")
          return
      }
      optionAlertVC.lbl_title.text = title ?? "Warning"
      optionAlertVC.lbl_message.text = message
      optionAlertVC.iv_icon.image = UIImage(named: "icon_warning")
      optionAlertVC.btn_ok.backgroundColor = UIColor.MyTheme.greenSuccess
      optionAlertVC.btn_ok.setTitle(okTitle, for: .normal)
      optionAlertVC.btn_ok.titleLabel!.adjustsFontSizeToFitWidth = true
      optionAlertVC.btn_cancel.backgroundColor = UIColor.MyTheme.redWarning
      optionAlertVC.btn_cancel.setTitle(dismissTitle, for: .normal)
      optionAlertVC.btn_cancel.titleLabel!.adjustsFontSizeToFitWidth = true
      optionAlertVC.btn_cancel.titleLabel?.numberOfLines = 1
  
      optionAlertVC.btn_ok.actionHandle(controlEvents: .touchUpInside, ForAction: ok)
      optionAlertVC.btn_cancel.actionHandle(controlEvents: .touchUpInside, ForAction: cancel)
  
      viewController.present(optionAlertVC, animated: true, completion: nil)
  }
  </code></pre>
  
  <p><strong>UIButtonExtension:</strong></p>
  
  <pre><code>extension UIButton {
      fileprivate func actionHandleBlock(action:(() -&gt; Void)? = nil) {
          struct __ {
              static var action :(() -&gt; Void)?
          }
          if action != nil {
              __.action = action
          } else {
              __.action?()
          }
      }
  
      @objc private func triggerActionHandleBlock() {
          self.actionHandleBlock()
      }
  
      func actionHandle(controlEvents control :UIControl.Event, ForAction action:@escaping () -&gt; Void) {
          self.actionHandleBlock(action: action)
          self.addTarget(self, action: #selector(UIButton.triggerActionHandleBlock), for: control)
      }
  }
  </code></pre>