开发者

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?


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.

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

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


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.


You could do a search in the whole project... I don't have a screen ready but I know Xcode can.


Haven't seen this in Xcode. Just FYI you are able to do that with AppCode though.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜