Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
666 views
in Technique[技术] by (71.8m points)

ide - Find method references in Xcode

Is there a way in Xcode to find all the places where a method or property has been been called?

In Eclipse, for example, you can right-click a method and select Find references. Is there anything similar in Xcode?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. Select the method you're interested in, or position the text cursor within it.
  2. Open the "Related Files" menu via the icon at the top-left of the Editor. (It's the button immediately to the left of the back button).
  3. Go to the "Callers" submenu for a list of all methods that call the selected method, and click any of them to jump to that file and method.

In pictures...

Screenshot of steps 1 and 2 above.

Screenshot of step 3 above

A couple of notes:

  • You can do this for properties too.
  • Note that when you select a calling method from the Callers menu to jump to where your method was called, Xcode highlights only the first call. Each calling method will only show up in the 'Callers' list once, even if it contains many calls to your method. So if you're trying to make some change at every place in your application where a method is called, be careful not to miss some in places where a calling method contains two calls to the method you're interested in.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...