I know how to add an IBAction to a button by dragging from the interface builder, but I want to add the action programmatically to save time and to avoid switching back and
Swift answer:
myButton.addTarget(self, action: "click:", for: .touchUpInside) func click(sender: UIButton) { print("click") }
Documentation: https://developer.apple.com/documentation/uikit/uicontrol/1618259-addtarget