Creating and Connecting an Action

    Steps
  1. Choose View > Assistant Editor > Open Assistant Editor.

  2. In the primary editor, open the user interface document that contains the object that invokes the new action.

  3. In an assistant editor, open the header file to which to add the action-method declaration.

  4. Control-drag from the object to the header file.

  5. Choose Action from the Connection menu.

  6. Enter the name of the action method, and click Connect.

Connect an object to the declaration of a new action method in a header file.



image: ../art/create_and_connect_action_button.png

As you Control-drag from an object to your source code, Xcode indicates where a new action is valid. After you enter the name of the action, Xcode declares the action for you and connects the object to it.

Xcode also inserts a skeletal definition for the new action in the implementation file. You need to add the source code that implements the action. You can Option-click the name of the implementation file in the source editor’s jump bar to open the implementation file alongside the header file.

The video shows connecting a button matrix to a new action in a window controller class.