Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BeauNouvelle/3bdbe6d83d11148bf00fafa17d07d2e5 to your computer and use it in GitHub Desktop.
Save BeauNouvelle/3bdbe6d83d11148bf00fafa17d07d2e5 to your computer and use it in GitHub Desktop.
convenience init(title: String?, style: UIBarButtonItem.Style, closure: @escaping UIBarButtonItemTargetClosure) {
self.init(title: title, style: style, target: nil, action: nil)
targetClosure = closure
action = #selector(UIBarButtonItem.closureAction)
}
@objc func closureAction() {
guard let targetClosure = targetClosure else { return }
targetClosure(self)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment