Programming

Xcode에서 메소드 참조 찾기

procodes 2020. 5. 29. 23:09
반응형

Xcode에서 메소드 참조 찾기


Xcode에서 메소드 또는 속성이 호출 된 모든 위치를 찾는 방법이 있습니까?

예를 들어 Eclipse에서 메소드를 마우스 오른쪽 단추로 클릭하고 참조 찾기를 선택할 수 있습니다 . Xcode에 비슷한 것이 있습니까?


  1. 관심있는 방법을 선택하거나 그 안에 텍스트 커서를 놓습니다.
  2. 편집기의 왼쪽 상단에있는 아이콘을 통해 "관련 파일"메뉴를 엽니 다. (뒤로 버튼의 바로 왼쪽에있는 버튼입니다).
  3. 선택한 메소드를 호출하는 모든 메소드 목록을 보려면 "Callers"하위 메뉴로 이동 한 후 이들 중 하나를 클릭하여 해당 파일 및 메소드로 이동하십시오.

사진에서 ...

위의 1 단계와 2 단계의 스크린 샷

위의 3 단계 스크린 샷

몇 가지 메모 :

  • 속성에 대해서도이 작업을 수행 할 수 있습니다.
  • 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.

Yes, open the Assistant editor and instead of Counterparts select Callers.

여기에 이미지 설명을 입력하십시오


As of XCode 4.5 you can click on "Show find options" within the search field of the Search Navigator. There you can specify "Symbol References"

여기에 이미지 설명을 입력하십시오


Place the insertion point in a method invocation or declaration and choose Find > Find Selected Symbol In Project. For multipart selectors this will only highlight the first part but searching does seem to work relatively reliably. You can also use Find Call Hierarchy which highlights the entire line instead.

The corresponding contextual menu item (Find Selected Symbol in Workspace) also works, but it's a bit trickier to make work properly. Make sure no text gets selected otherwise it'll search for the selected word rather than the entire selector. To do so, you can click with the left mouse button prior to clicking with the right mouse button (or Control-clicking) in the same location. There's no such issue with the contextual Find Call Hierarchy.


Select function, press cmd-shift-A, "Callers"

여기에 이미지 설명을 입력하십시오


대안 으로 Xcode 9에서 변수 또는 메소드 의 모든 참조를 찾아서 Find navigator다음과 같이 설정할 수 있습니다Find -> References -> Matching Word

UI는 다음과 같습니다

여기에 이미지 설명을 입력하십시오


xcode 4를 사용하면 참조를 마우스 오른쪽 버튼으로 클릭하고 "정의로 점프"를 선택할 수 있습니다.

참고 URL : https://stackoverflow.com/questions/7145045/find-method-references-in-xcode

반응형