How can the action for a custom UIBarButtonItem in Swift be set?
The following code successfully places the button in the navigation bar:
var b = UIB
Swift 5
if you have created UIBarButtonItem in Interface Builder and you connected outlet to item and want to bind selector programmatically.
Don't forget to set target and selector.
addAppointmentButton.action = #selector(moveToAddAppointment)
addAppointmentButton.target = self
@objc private func moveToAddAppointment() {
self.presenter.goToCreateNewAppointment()
}