Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. enum AlertAction {
  2. case title(title: String)
  3. case titleWithPopAction (title: String)
  4. case titleWithSettingsAction (title: String)
  5. case titleWithAppStoreAction (title : String)
  6. case titleWithHandler (title: String, completionHandler: AlertControllerCompletionHandler?)
  7.  
  8. var action: UIAlertAction {
  9. switch self {
  10.  
  11. case let .title(title):
  12. return UIAlertAction(title: title, style: .default) { _ in }
  13.  
  14. case let .titleWithPopAction(title):
  15. return UIAlertAction(title: title, style: .default) { _ in
  16. NavigationManager.shared.popVC() //Create Navigation manager class in your app which handles POP, PUSH, PRESENT VC.
  17. }
  18.  
  19. case let .titleWithSettingsAction(title):
  20. return UIAlertAction(title: title, style: .default) { _ in
  21. NavigationManager.shared.popVC(animated: false)
  22. afterDelay(0.2) {
  23. UIApplication.shared.openURL(URL(string:"prefs:root")!)
  24. }
  25. }
  26.  
  27. case let .titleWithAppStoreAction(title):
  28. return UIAlertAction(title: title, style: .default) { _ in
  29. afterDelay(0.2) {
  30. UIApplication.shared.openURL(URL(string: k_App_Store_url)!)
  31. }
  32. }
  33.  
  34. case let .titleWithHandler(title, completionHandler):
  35. return UIAlertAction(title: title, style: .default) { action in
  36. completionHandler?(action)
  37. }
  38.  
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement