Finding all references of a variable or a method in Xcode4

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.


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. :)


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.