Alerts

UIAlertController displays an alert message in a small dialog box. Additionally you can associate an action with the alert controller.

let alert = UIAlertController.init(title: "Error", 
                                   message: "An unknown error has occurred", 
                                   preferredStyle: .alert)

let action = UIAlertAction.init(title: "Ok", 
                                style: .default) { _ in
   print("Ob button is pressed")
}

alert.addAction(action)
present(alert, animated: true, completion: nil)
Show error message in controller

The alert may contain one or more text fields that allow the user to enter some data.

Show prompt alert dialog