Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • 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