Advertisement
Guest User

UIAlertController interface

a guest
Nov 30th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.70 KB | None | 0 0
  1. struct ActionSheet {
  2.     let title: String
  3.     let buttons: [Button]
  4.    
  5.     var AlertController: UIAlertController {
  6.         let alert = UIAlertController(title: self.title, message: nil, preferredStyle: .ActionSheet)
  7.        
  8.         for button in self.buttons {
  9.             alert.addAction(button.AlertAction)
  10.         }
  11.        
  12.         alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))
  13.        
  14.         return alert
  15.     }
  16. }
  17.  
  18. struct Button {
  19.     let title: String
  20.     let handler: ((UIAlertAction) -> Void)?
  21.    
  22.     var AlertAction: UIAlertAction {
  23.         return UIAlertAction(title: self.title, style: .Default, handler: self.handler)
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement