UIAlertView in Swift

In Swift and iOS 8 SDK you can present an alert view as shown in the code below :

 

var alert = UIAlertController(title: ÔÇťAlert Title”, message: “Message”, preferredStyle: UIAlertControllerStyle.Alert)alert.addAction(UIAlertAction(title: “OK”, style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)

You can also add destructive and cancel actions by setting the style property to Destructive and Cancel respectively.

Leave a Reply

Your email address will not be published. Required fields are marked *