For swift it is very simple.
//Creating the alert controller
//It takes the title and the alert message and prefferred style
let alertController = UIAlertController(title: "Hello Coders", message: "Visit www.simplifiedios.net to learn xcode", preferredStyle: .Alert)
//then we create a default action for the alert...
//It is actually a button and we have given the button text style and handler
//currently handler is nil as we are not specifying any handler
let defaultAction = UIAlertAction(title: "Close Alert", style: .Default, handler: nil)
//now we are adding the default action to our alertcontroller
alertController.addAction(defaultAction)
//and finally presenting our alert using this method
presentViewController(alertController, animated: true, completion: nil)