Posts

Showing posts from November, 2020

Create Message Box with completion action

This is to create a method to show message with title in a contain (UIViewController) and when user tap on Close button, completion action, a  closure, will be act   1. Declare method: public func showMessage (title : String , message : String , container: UIViewController ,   completion: @escaping () -> Void ){         let alertController = UIAlertController (title: "" , message: message , preferredStyle: . alert )         //the cancel action doing nothing         let doneAction = UIAlertAction (title: "Close" , style: . default ) { _ in             completion()         }         alertController. addAction (doneAction)         container. present (alertController, animated: true , completion: nil )     } 2. Call the method: showMessage (title: "Title" , message: "message", container: theUIViewControll...