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?
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?
In pictures...
A couple of notes:
^1
so I'm usually able to press ^1, c, enter
to bring up the list.
– Peter Theill
Nov 21 '13 at 22:27
init
, and this brings up any method named init
as well. Not so smart...
– Nathan H
Aug 28 '16 at 14:11
Yes, open the Assistant editor and instead of Counterparts select Callers.
As of XCode 4.5 you can click on "Show find options" within the search field of the Search Navigator. There you can specify "Symbol References"
Place the insertion point in a method invocation or declaration and choose Find > Find Selected Symbol In Project. For multipart selectors this will only highlight the first part but searching does seem to work relatively reliably. You can also use Find Call Hierarchy which highlights the entire line instead.
The corresponding contextual menu item (Find Selected Symbol in Workspace) also works, but it's a bit trickier to make work properly. Make sure no text gets selected otherwise it'll search for the selected word rather than the entire selector. To do so, you can click with the left mouse button prior to clicking with the right mouse button (or Control-clicking) in the same location. There's no such issue with the contextual Find Call Hierarchy.
As an alternative you can find all references of a variable or a method in Xcode 9 using Find navigator
and setup it like Find -> References -> Matching Word
The UI looks like
With xcode 4 you can now right click on references and select "jump to definition."