OneGuyInDc
OneGuyInDc

Reputation: 1565

Xcode quickly jump to Action associated with a Control

Is there a quick way to jump to an action associated with a control.

Say there is a button on a XIB file that has an associated action. The way to find the code associated with this is rather tedious. Is there a short cut that can quickly jump to the code.

I am spoiled by Visual Studio - double click on a button and it takes you to it's handler

Upvotes: 14

Views: 2237

Answers (2)

Paul B
Paul B

Reputation: 5115

I would advise to use ^+++Enter to get to referenced code file. There you can search for @IBActions or @Outlets. If a UIButton has a segue attached, this method won't help to find it. To review a list of actions, segues and outlets you can select an object on the storyboard and press ++7 to open Connections Inspector on the right pane.

Upvotes: 1

mistercake
mistercake

Reputation: 723

The fastest way I know to at least get quickly to the source file in which the action resides is the following:

  1. select the button in the UI editor
  2. hit ctrl+1 (this will open the “Related Files” drop down)
  3. navigate to the “Sent Actions” sub-menu, e.g. via s, enter
  4. select the relevant class (I think in this case there can only be one, so just hit enter again)

Once you are in the class, the action should be easy to find. If that's not the case, because your source file is so big, type ctrl+6 to open the “Document Items” drop down and start typing the name of the action. Once you see the action, select it via keyboard or mouse.

If you often don't know the name of the action, you will have to look it up before navigating to the class, e.g. by right clicking on the button.

Upvotes: 5

Related Questions