Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to jump to a specific method in Xcode?

Tags:

xcode

xcode4

People also ask

How do you jump to define in Xcode?

To directly jump to a definition, you can combine ^ ctrl + ⌘ command + click .

How do I search for a function in Xcode?

Find Text or Patterns in Your Source Code To find text in a file, open the file in the Xcode source editor and choose Find > Find from the menu bar. Xcode displays the Find bar and its search controls at the top of the file. Enter a search term. Xcode searches the file, highlights matches, and notes how many it finds.

How do I select code in Xcode?

Cmd + l it's already a shortcut in the newest Xcode version so you'll have to apply it to Ctrl + cmd + l or something.


I think this is what you're looking for:

Type ctrl-6 to activate the "Show Document Items" in the "Jump Bar". Then start typing part of the method you are looking for to narrow the results.

Example:

To jump straight to - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

Type ctrl-6, type "cellFor", arrow down so the method is highlighted, and press Enter. The Editor will jump right to that method.

Incidentally, you can use ctrl-1, ctrl-2, ctrl-3, etc. to access the different sections of the "Jump Bar".


If I understand you correctly, try Command-Shift-O. It also doubles as a file finder.


Perhaps I'm not understanding what you need, but it seems like you have a couple of options.

  • Control+Command+J should take you to a definition.
  • Control+Command+Up/Control+Command+Down will toggle between .h/.m files.
  • While in the .m file, I use the dropdown for the methods often.

If you want to press a command key sequence like Command + Option + to jump to the next method, or Command + Option + to jump to the previous method, there is no such animal in Xcode. Prior macOS development tools had such a capability, but Xcode is seriously lacking in the basics...

The fastest jump back and forth in methods in a source file is to perform a Command + F (Find) on [\-\+][ \t]*\( as a regular expression. Then you can Command + G (Find Next) to go to the next method or Command + Shift + G (Find Previous) to go to the prior method.

If you are disciplined in your method definitions, you might be able to search for - ( or + ( as a normal text string instead... a tad faster.

If this is a serious itch to scratch, maybe it is worth creating an Xcode plugin (as silly as this sounds for such a basic feature)... and post a link here for the rest of us ;-)


Select a symbol (could be a method, but doesn't have to be) and right-click (or control-click). The contextual menu that pops up has a "Jump to definition" command. Control-command-J is a shortcut for that.

If the thing you're looking for isn't visible, you can use the Search Navigator (Command-3) to search through the code.

Depending on what you're looking for, you may also find the Quick Help feature in the Utilities panel helpful. If you select a symbol, Quick Help will give you at least some basic information about that symbol. For symbols in the iOS or MacOS X API's, you get quite a bit of help. If you've selected your own symbol, it'll tell you where that symbol is declared, and you can click on the file name to jump to the declaration.

I don't think there's a command to jump to the next method (where in the method would you want to jump to?). If you have a need for that sort of thing, you might find Xcode's code folding features useful. You can fold an entire method or just some of the blocks within the method. Very helpful for getting the lay of the land when you're looking at a large file for the first time.