Reputation: 38654
I am new to Xcode. I am not sure if there is a way to view a variable's references just like "Find all references" in Visual Studio by right click on a var?
For example, in my .h file, I would like to know or view all the references for property isSet:
@interface MyInterface {
...
BOOL isSet; // view all references to this var?
...
}
Upvotes: 16
Views: 6865
Reputation: 349
Find selected symbol in workspace is what you need
⇧ + ⌃ + ⌘ + F
(or you
can have a custom one)Does basically the same search as Refactor -> Rename does
Upvotes: 0
Reputation: 734
Update for XCode 12: right click on definition -> Show code actions -> Callers...
This will show every place in the project where this method or property is referenced.
Upvotes: 0
Reputation: 154725
You're conflating two different things in your question: finding references to a variable, and finding references to a property. Finding references to a property can be done via the 'Related Files' menu, as described in my answer here: https://stackoverflow.com/a/17931752/1709587
Finding references to a variable can be sort-of done via 'Find Navigator' tab of the Navigator. (That's the magnifying-glass-icon tab of the left side menu.) Go to Find
-> References
-> Matching
and type in the variable you're looking for. That said, I can't see that this is particularly useful, because:
If you truly, truly do need the functionality you're asking for, and neither the 'Related Files' menu, Find
-> References
, nor a simple text search will do, then your only options are to use some third party tool like AppCode or the (cumbersome, slow) 'refactor' hack proposed by Karim.
Upvotes: 0
Reputation: 15589
I was looking for similar option. I do not know why XCode did not included that. But there is a work around I use until Apple give that option in XCode.
Try this in the source code (.m) file,
Select the symbol, right click -> Refactor -> Rename
-> Give a name whatever you wish, then press Preview.
Now you can find all the references. Now you can Cancel
it or do not rename it. :)
Upvotes: 2
Reputation: 1298
i'm using xcode ver 4.5 and i can select the method or property, right click and pick Find Selected Text in Workspace...
Upvotes: 0
Reputation: 2651
Beside Xcode, there is AppCode IDE from JetBrains. And in AppCode it is easily possible, just select Search
--> Find Usages
.
Upvotes: 2
Reputation: 118812
Try using: Find in project -> As symbol context menu. Sometimes you may want to search as definition instead.
Upvotes: 4