ChrisP
ChrisP

Reputation: 10116

How do you find all references to a method or property in Xcode?

If you have a method, e.g., loadMediaImages in a .h file, how do you find all references to that method in the project? In Visual Studio there is a "Find All References" option on the content menu when you highlight and click the method name. Anything similar in Xcode?

Upvotes: 6

Views: 7289

Answers (4)

Petru Lutenco
Petru Lutenco

Reputation: 349

Find selected symbol in workspace is what you need

  • right click on the method/property -> Find -> Find selected symbol in workspace
  • focus the property/method and press ⇧ + ⌃ + ⌘ + F (or you can have a custom one)

Does basically the same search as Refactor -> Rename does

Upvotes: 2

karim
karim

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 see all the references. You can Cancel/do not rename it. :)

Or press Cmd + Shift + F, and choose optons Find > References > Matching or Containing. But it will search all text with similar name. Not elegant like Refactoring.

Upvotes: 3

Anthony F
Anthony F

Reputation: 6206

Using the "Search Navigator" it's possible to search for symbol references within a project or workspace. Click on the little magnifying glass icon in the search box to "Show Find Options", and then select the Style: Symbol References.

Search Navigator with find options

Note: This is in Xcode 4.6, but may have been present in earlier versions.

Upvotes: 5

Evan Mulawski
Evan Mulawski

Reputation: 55334

If I'm not mistaken, Xcode 4 (not sure about previous versions) does not support a Find All References search. You can perform a text search within the entire project by pressing Shift+Cmd+F (Find in Workspace in the Edit menu), but this does not find exact "references", just matching text. You're best bet is using the Refactoring menu, as talked about in Finding all references of a variable or a method in Xcode4, but it is not very clean and requires more work than it should.

Upvotes: 0

Related Questions