Skip to content

Instantly share code, notes, and snippets.

@freesia
Last active August 29, 2015 14:10
Show Gist options
  • Save freesia/7bbc0449948bd14cb16c to your computer and use it in GitHub Desktop.
Save freesia/7bbc0449948bd14cb16c to your computer and use it in GitHub Desktop.
alertview_ios7_ios8
if let alertController: AnyClass = NSClassFromString( "UIAlertController" )
{
// iOS 8: use UIAlertController
let alert = UIAlertController( title: "", message: "", preferredStyle: .Alert )
alert.addAction( UIAlertAction( title: "OK", style: .Default, handler: nil ))
presentViewController( alert, animated: true, completion: nil )
}
else
{
// iOS 7: use UIAlertView
let alertView = UIAlertView( title: "", message: "", delegate: nil, cancelButtonTitle: nil, otherButtonTitles: "OK" )
alertView.show()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment