Skip to content

Instantly share code, notes, and snippets.

@mgp
Created February 26, 2015 01:12
Show Gist options
  • Save mgp/37f1d2d452f526ba52f1 to your computer and use it in GitHub Desktop.
Save mgp/37f1d2d452f526ba52f1 to your computer and use it in GitHub Desktop.
/**
UIAlertViewDelegate used when the user can only go back, and so the associated handler
has no parameters.
*/
private class BackOnlyErrorDelegate: NSObject, UIAlertViewDelegate {
private let handler: () -> Void
private init(handler: () -> Void) {
self.handler = handler
}
func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
switch buttonIndex {
case alertView.cancelButtonIndex:
handler()
default:
logAndAbort("UIAlertView selected an option that was not cancel")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment