let Msg:String = "Hello" let alert = UIAlertController(title: "Alert", message: Msg, preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { action in switch action.style{ case .default: print("default") case .cancel: print("cancel") case .destructive: print("destructive") }})) self.present(alert, animated: true, completion: nil)