4

I added the following comment with backtick for code:

/** Checks if the given data is of type `list`. */
+ (BOOL)isList:(id)object {
    // ..
}

but the backtick prints as in the Xcode quick help:

enter image description here

How to get Xcode to display code formatted properly? It works fine when documenting Swift source.

5
  • 4
    try using @p or @c this post is a bit old, but still has a bunch of useful options: stackoverflow.com/a/19169271/7833793 alternatively if you're trying to do a larger code block using @code // @endcode Commented Apr 29, 2019 at 17:50
  • 1
    So you’re saying Swift uses markdown but Objective C doesn’t. What an odd thing for Apple to do. Commented Apr 29, 2019 at 17:58
  • 1
    Sure enough, /// Checks if the given data is of type @c list. works. Weird. Commented Apr 29, 2019 at 18:02
  • @R4N Maybe post your comment as an answer, including pointing out that for Objective-C code, you use the Objective-C style, and for Swift you use the markdown style. Commented Oct 25, 2021 at 7:03
  • 1
    @Kalle Added an answer, thanks for the follow up. Commented Oct 25, 2021 at 19:34

1 Answer 1

3

As discussed in the comments above, in Objective-C documentation comments you can use @p or @c to display Typewriter font in the QuickHelp documentation. Whereas Swift documentation comments accept Markdown (using the backticks)

While this answers is relatively old, it still lists a good amount of the options available in Objective-C documentation comments: https://stackoverflow.com/a/19169271/7833793

Here's a brief example:

/// Here's how to use @c Typewriter @c Font
- (void)myMethod {}

Which displays this in the QuickHelp: enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.