Last active
September 2, 2016 17:06
-
-
Save yoman07/bd18199c4f903836912da88330f2ead6 to your computer and use it in GitHub Desktop.
Display alert view with settings button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AlertControllerFabric.swift | |
// Mapa Turystyczna | |
// | |
// Created by Roman Barzyczak on 05.04.2016. | |
// | |
import Foundation | |
class AlertHelper { | |
enum AlertType { | |
case GPSDenied | |
} | |
class func factoryFor(type : AlertType) -> UIAlertController { | |
var title:String! | |
var message:String! | |
let cancelAction:UIAlertAction! | |
let settingsAction:UIAlertAction! | |
switch type { | |
case .GPSDenied: | |
title = NSLocalizedString("Enter your title here", comment:"" ) | |
message = NSLocalizedString("Enter your message here.", comment:"" ) | |
cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment:"" ), style: .Cancel, handler: nil) | |
settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment:"" ), style: .Default, handler: { action in | |
UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!) | |
}) | |
break | |
} | |
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert) | |
alertController.addAction(cancelAction) | |
alertController.addAction(settingsAction) | |
return alertController | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment