Swift (iOS/macOS): ダイアログの表示

Simulator Screen Shot 2016.07.17 17.30.03

    override func viewDidAppear(animated: Bool) {
        
        let alert = UIAlertController(title: "title", message: "message", preferredStyle: .Alert)
        alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (action: UIAlertAction) in
            self.dismissViewControllerAnimated(true, completion: nil)
        }))
        alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action: UIAlertAction) in
            self.dismissViewControllerAnimated(true, completion: nil)
        }))
        self.presentViewController(alert, animated: true, completion: nil)
    }