How to connect IBAction and menu item to the first responder?

In the Xcode storyboard, I am trying to connect an IBAction from the ViewController to a menu item in the application scene (menu bar).

I found a solution saying that I should connect the menu item to the first responder. Then the first responder to IBAction, since the first responder represents in all the scenes. Thus, the first responder can get the action from the menu bar first as zero, and then bind it to IBAction.

However, I cannot understand how to connect the menu item to the first responder and the first responder to IBAction. When I press Ctrl + drag the menu item in First Responder, it shows only the predefined actions. And I cannot ctrl + drag the ViewController in the First Responder onto the viewController scene in general.

How to connect IBAction and menu item to the first responder?

+4
source share
1 answer

When you create an IBAction by dragging it from IB or writing yourself, these actions are added to the list of actions in the FirstResponder object in IB. The next step is to drag the menu item from the library of objects into the menu bar, and then right-click the firstResponder object and search for the desired action and associate it with the menu item that you recently added.

Here is a screenshot. IB screenshot

+7
source

All Articles