Swift alert view with OK and Cancel: which button tapped?

PHOTO EMBED

Sat Mar 05 2022 07:51:17 GMT+0000 (Coordinated Universal Time)

Saved by @hasnat #alert #ios #swift

let refreshAlert = UIAlertController(title: "Offer Sent", message: "Your offer has been sent Successfully", preferredStyle: UIAlertController.Style.alert)

                refreshAlert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action: UIAlertAction!) in
                    self.dismiss(animated: true, completion: nil)
                  print("Handle Ok logic here")
                  }))
                
                refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: { (action: UIAlertAction!) in
                    self.dismiss(animated: true, completion: nil)
                  print("Handle Cancel logic here")
                  }))

                self.present(refreshAlert, animated: true, completion: nil)

content_copyCOPY

https://stackoverflow.com/questions/25511945/swift-alert-view-with-ok-and-cancel-which-button-tapped