5

I am adding a hyperlink into the comments for my code for future reference. The hyperlink is being added by copying the url from Safari and then pasting it into Xcode.

The problem is that I can't control the hyperlink now that it has been pasted into my code and it is being modified when additional text is added.

Example URL: https://link.to.resource/DID/
How I want the link to be displayed:  Device ID (listed in https://link.to.resource/DID/.)

How can I add the additional text without modifying the link location? When I add ./ to the end, it becomes part of the link and the address no longer works.

4
  • Can you not simply add a space after the last / in the link? Commented May 10, 2017 at 21:29
  • If that is the only option. It just seems very strange that there isn't anything in the edit menu that allows you to counter the default behavior.
    – C1pher
    Commented May 10, 2017 at 21:30
  • But why would you want to be able to add characters directly after the end of the link? Wouldn't you always have a space (or in your case a )) directly after the end of the url? Commented May 10, 2017 at 21:32
  • Not at the end of a sentence. The period doesn't usually hang in front of a blank space. And it's only a workaround. It doesn't clarify if Xcode actually offers the feature to edit a hyperlink and I simply can't find it.
    – C1pher
    Commented May 10, 2017 at 21:35

1 Answer 1

9

The simplest solution is to include a space or closing paren at the end of the link.

You can also use comment markup to add a link to Xcode's Quick Help Documentation.

/// Device ID (listed [here](https://link.to.resource/DID/))

This will create a quick help description that looks like this:

A screenshot of the quick help description

If you are really set on a period at the end of the link, you can add it inside the [] at the end of the link text. This is what Apple does in one of their examples for link markup. This adds a period at the end, but the period is styled as part of the link text.

/*:
  For more information, see [The Swift Programming Language.](http://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/)
 */

Apple's Link Markup Documentation: https://developer.apple.com/library/content/documentation/Xcode/Reference/xcode_markup_formatting_ref/Links.html#//apple_ref/doc/uid/TP40016497-CH18-SW1

Not the answer you're looking for? Browse other questions tagged or ask your own question.