Search code examples
xcodeeventsstoryboardxcode9ibaction

Xcode 9: How can I set the action event of an IBAction


I'd like to change the action event of a button in a storyboard in Xcode 9. In Xcode 8, when control clicking and dragging a button to the code, there was a way to set the action event. In Xcode 9, this selection is missing. Was this setting removed or can I find it somewhere else?

Thanks in advance.

In Xcode 9:

action setting popup in Xcode 9

In Xcode 8:

action setting popup in Xcode 8


Solution

  • NSButton does not differentiate between events in the same way UIButton does. Your example picture for Xcode 8 shows the popup that comes up after connecting a UIButton.

    If you want to invoke the IBAction for multiple events, you can use sendAction(on:).