1

In regular code if I write something like:

[self performAnActionWithArg:myArg andThisArg:myArg2];

Then I can CMD click on "performAnActionWithArg:" and it will take me to the declaration of that method.

However, how can I reference a method within a comment to get xCode to perform the same cross linking behaviour? Is it even possible? I've tried lots of variations such as:

// See [MyClass performAnActionWithArg:myArg andThisArg:myArg2]

but xCode will not see performAnActionWithArg:andThisArg: as a method I can navigate to. Any ideas?

techsMex
  • 594
  • 4
  • 16
  • 1
    I think you are SOL. However see http://stackoverflow.com/questions/13751906/does-objective-c-have-an-equivalent-to-java-annotations where some people talk about 3rd party products for methods annotation. Perhaps that might help. – Peter M Jan 20 '15 at 22:31

1 Answers1

1

Not by cmd-clicking but maybe by other means.

Xcode tries to recognize method names to make cmd-click work. You can see this because if you hold down the cmd key and hover over the method, the text is highlighted in blue, even in a comment. But in commented code Xcode can't use the compiler to work out the correct method name, so it often guesses the wrong text to highlight. For example, with this line:

Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];

Cmd-clicking works fine, but if I comment it out, the wrong text is highlighted: wrong highlighting Xcode tries to look up something named dequeueReusableCellWithReuseIdentifier:kCellID, which doesn't exist, so it reports "symbol not found".

A comment that only contains the method name almost works:

// dequeueReusableCellWithReuseIdentifier:forIndexPath:

But not quite, because Xcode misses the final :.

However if you select the entire method name and then right-click on it, one of the menu options is "jump to definition", which works: contextual menu This isn't nearly as convenient as cmd-click, but it works.

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170