Find method references in Xcode

Java Ka Baby picture Java Ka Baby · Aug 22, 2011 · Viewed 50.1k times · Source

Is there a way in Xcode to find all the places where a method or property has been been called?

In Eclipse, for example, you can right-click a method and select Find references. Is there anything similar in Xcode?

Answer

Mark Amery picture Mark Amery · Jul 29, 2013
  1. Select the method you're interested in, or position the text cursor within it.
  2. Open the "Related Files" menu via the icon at the top-left of the Editor. (It's the button immediately to the left of the back button).
  3. Go to the "Callers" submenu for a list of all methods that call the selected method, and click any of them to jump to that file and method.

In pictures...

Screenshot of steps 1 and 2 above.

Screenshot of step 3 above

A couple of notes:

  • You can do this for properties too.
  • Note that when you select a calling method from the Callers menu to jump to where your method was called, Xcode highlights only the first call. Each calling method will only show up in the 'Callers' list once, even if it contains many calls to your method. So if you're trying to make some change at every place in your application where a method is called, be careful not to miss some in places where a calling method contains two calls to the method you're interested in.