There'a a similar question here but I couldn't make use of the answers in XCode 4. I googled it but I couldn't come up with anything useful either. What's your effective method of getting this information?
7 Answers
Find in project, though if you are searching to change the name everywhere, better would be to use the Refactoring menu.
EDIT: You can use Refactoring to find where a specific variable is referenced. Select the variable and choose Edit->Refactor->Rename. In the refactoring screen, rename the variable (just add _ at the end or something) and click preview. it will show everywhere in the project that variable is referenced. Click on each file to see the lines where the variable is called. After you're done just cancel the refactor.

- 11,254
- 3
- 32
- 60
-
I'm searching to understand the calling paths, actually. Yeah, I use the refactoring menu for renaming, etc..If you read my comment above, that's why Find in project does not work for me. Thanks for the answer. – aslı Mar 28 '11 at 10:20
-
Edited my answer. It's kind of a hack but it does the job I guess. – Kirby Todd Mar 28 '11 at 10:28
-
:] Yeah I can use this, nice hack. – aslı Mar 28 '11 at 10:34
-
Good ol' Xcode, crashes every time I attempt a refactor of a function. – Nic Foster May 18 '12 at 17:48
-
33So surprise when XCode doesn't support many importance features which we can easily do in eclipse, visualstudio, netbean,... – Nguyen Minh Binh Dec 12 '12 at 07:18
-
3+1 for the refactor trick. Lame that it has the ability to do this, but doesn't just offer a simple way to find references. Oh Xcode. – devios1 Mar 21 '13 at 22:40
-
This approach is really slow and doesn't let you jump to the references you're interested in. For method and property references, you're probably better off using the 'Related Files' menu, as I describe here: http://stackoverflow.com/a/17931752/1709587 For variable references, an ordinary text search with cmd-f within the file in which the variable is declared should almost always suffice, unless you're routinely using public member variables instead of properties. – Mark Amery Oct 05 '13 at 11:18
I highly recommend you try appCode, by JetBrains. JetBrains have a lot of experience making IDEs (yes, even more than Apple ;) and have done an amazing job with even the EAP of appCode. Find usages, plus a lot more works very nicely.
You can simply open your existing xcode project file in appCode, then Search --> Find Usages.

- 1,985
- 1
- 16
- 23
-
-
well, it is free for now, so get in quick and find-usages. Also - it may pay for itself in the longer run. – npellow Apr 10 '11 at 23:11
-
:) yeap, I downloaded it. Maybe I can ask my company about this after that 30 days trial. – aslı Apr 11 '11 at 07:27
As Casebash points out here, there actually is a way to search for symbols in Xcode, but unfortunately it's not at all intuitive or convenient to use.
First, open the Search Navigator (Cmd+Shift+F) and change the Style
to Symbol References
. Then type the name of the symbol into the search box (if it's just a variable name you can select it in the code and type Cmd-E to copy it to the search field). If searching for a method, be sure to use the colon-delimited notation like so:
doSomethingForObject:withParameter:andOtherParameter:
Now if someone could convince Apple to just add a contextual menu item for this, I would be a happy camper. :)
The best way is to do a full text search of the project: CMD-SHIFT-F.

- 1,985
- 1
- 16
- 23
-
But assume that I have two classes that have the insance variable named ID, and I want to know the references to the instance variable of my first class. If I do a full search, this will bring me the results related to the two classes. That's why I need a different searching mechanism. Thanks for the answer though.. – aslı Mar 28 '11 at 10:18
-
4Yeah - it is odd that XCode doesn't support proper, semantic, find-usages. The 'refactor' option definitely does this, so making a find-usages should not be too hard. – npellow Mar 28 '11 at 23:05
-
Sadly this is usually my default solution. As a result I've started changing my coding habits to name my methods globally unique to facilitate this... (an IDE's missing feature coercing changes in my coding habits :( ) – pretzels1337 Feb 05 '13 at 18:56
For methods and properties, just use the Related Files menu as I describe here: https://stackoverflow.com/a/17931752/1709587
For variables, there is no easy way to specifically find references, per se (you'll need to use AppCode or the ugly, slow, cumbersome refactor hack), but you shouldn't normally need to. Public member variables are rare in Objective-C, so generally variables are only referred to within the file in which they are declared. A plain text search for the variable name using cmd+f should suffice, usually.

- 1
- 1

- 143,130
- 81
- 406
- 459
I think instead of doing the refactor hack above. A faster way to find variable references of a particular class is to change the name of the variable (add a letter to the end) in the defining class and hit compile. The compiler will then give you an error for every place that referenced the original variable name.
@property (nonatomic, strong) NSString * url;
becomes
@property (nonatomic, strong) NSString * urlt;
and the compiler happily tells you of every place that uses it:

- 7,901
- 2
- 29
- 28
This is for Xcode 11 for finding the usages of a function, it took forever to find:
- Right click the name of the function.
- Select "Show Code Actions"
- Select "Callers..."
Not sure why Apple made this very basic functionality so complicated

- 167
- 2
- 15