Skip to content

Instantly share code, notes, and snippets.

@wh1pch81n
Created February 9, 2017 02:22
Show Gist options
  • Save wh1pch81n/e1feae9e439ce4bfac3b1584cb44ff8e to your computer and use it in GitHub Desktop.
Save wh1pch81n/e1feae9e439ce4bfac3b1584cb44ff8e to your computer and use it in GitHub Desktop.
A little extension that lets you "tap" a UIBarButtonItem programmatically
extension UIBarButtonItem {
public func programmaticallyTap() {
if let target = target
, let action = action
{
target.value(forKey: NSStringFromSelector(action))
}
}
}
barbutton.programmaticallyTap()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment