Last active
March 18, 2017 13:12
-
-
Save jakerockland/8c5635baf090b9b3c1868d7ece3cf5a6 to your computer and use it in GitHub Desktop.
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
// | |
// UIAlertController+Action.swift | |
// | |
import UIKit | |
/** | |
Extension to `UIAlertController` to allow direct adding of `UIAlertAction` instances | |
*/ | |
extension UIAlertController { | |
func addAction(title: String?, style: UIAlertActionStyle, handler: ((UIAlertAction) -> Void)?) { | |
let alertAction = UIAlertAction(title: title, style: style, handler: handler) | |
self.addAction(alertAction) | |
} | |
} |
@regexident There is no performance benefit or anything like that, I was previously using the implementation that you pointed out and found it to be a bit messy when being used frequently in big projects. This extension makes the usage a bit cleaner and also has the benefit of XCode's autocompletion.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jbastosneto Glad that you find it useful! 😄