UIAlertView is deprecated in iOS 8, but Swift supports iOS7, and you cannot use UIAlertController on iOS 7. Add the following method to solve the problem:
func showAlert(title:NSString, message:NSString,owner:UIViewController) { if let gotModernAlert: AnyClass = NSClassFromString("UIAlertController") { var alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)) owner.presentViewController(alert, animated: true, completion: nil) } else { let alertView = UIAlertView(title: title, message: message, delegate: self, cancelButtonTitle: "Cancel", otherButtonTitles: "OK") alertView.alertViewStyle = .Default alertView.show() } }
and call the method somewhere from the code as follows:
showAlert(APP_NAME,message: "Add your alert message here" ,owner: self)
Salam Rahmaniac Jan 19 '15 at 12:32 2015-01-19 12:32
source share