I have three view controllers, all with two buttons on the right and left sides of the navigation bar, as shown below on one of them.

I create these buttons programmatically, and instead of writing code in each respective view controller (VC), I decided to write a Helper class that creates the buttons.
class Helper: NSObject {
static func loadNavBarItems(vc: UIViewController) {
let profileButton = UIBarButtonItem()
let addButton = UIBarButtonItem()
let attributes = [NSFontAttributeName: UIFont.fontAwesome(ofSize: 20)] as [String: Any]
profileButton.setTitleTextAttributes(attributes, for: .normal)
addButton.setTitleTextAttributes(attributes, for: .normal)
profileButton.title = String.fontAwesomeIcon(name: .userCircle)
addButton.title = String.fontAwesomeIcon(name: .plus)
vc.navigationItem.leftBarButtonItem = profileButton
vc.navigationItem.rightBarButtonItem = addButton
}
func segueToProfile(vc: UIViewController) {
}
Then I call Helper.loadNavBarItems(vc: self)from each VC viewDidLoad().
What I'm trying to do now is to call a session when I click one of the buttons (let it be a profile button). So, I need to determine profile.action. So, in the Helper class, I need to write a function segueToProfilethat takes a view ( vc) contoller and runs performSegueWithIdentifier.
, , , Googling, - , , , .
.
.
: , segue .