Xcode: show documentation for my custom classes

How can I force Xcode to show my own documentation for custom classes, methods, etc.? I'm used to Java and Eclipse, which shows me documentation for my classes as shown here:

Eclipse showing Javadocs documentation

How can I achieve the same in Xcode? Are there special comments that Xcode can recognize and display?

Xcode showing generic documentation for NSObject


Solution 1:

As of Xcode 5.0, Doxygen and HeaderDoc formatting for variables and methods is automatically parsed and rendered in the Quick Help popover. More information about it here, but here's some key bits:

/**
 * Add a data point to the data source.
 * (Removes the oldest data point if the data source contains kMaxDataPoints objects.)
 *
 * @param aDataPoint An instance of ABCDataPoint.
 * @return The oldest data point, if any.
 */
 - (ABCDataPoint *)addDataToDataSource:(ABCDataPoint *)aDataPoint;

renders in Xcode as:

As for properties, it's as easy as:

/// Base64-encoded data.
@property (nonatomic, strong) NSData *data;

When option-clicked, this lovely popover appears:

Solution 2:

Well, it seems that for the classes the question hasn't still been answered, so I'll post my suggestions.

Just before the @interface MyClass : NSObject line in the MyClass.h file you use the comment like you did in your example, but adding some tags to display the text. For example the code below:

/**
 * @class GenericCell
 * @author Average Joe
 * @date 25/11/13
 *
 * @version 1.0
 *
 * @discussion This class is used for the generic lists
 */

will produce the following output: the output of the code above http://imageshack.com/a/img18/2194/kdi0.png

Solution 3:

Appledoc is the best option for generating xcode documentation at the moment. Doxygen is great, but it does not generate docsets that work very well for the popups you're talking about. Appledoc isn't perfect, but we moved over to it and have been really happy with the results.

enter image description here

Solution 4:

It is also possible to add some code snippet in documentation like the following

Code snippet in Function Documentation in Xcode

by adding the following code

 *  @code
 *  - (UIButton*) createButtonWithRect:(CGRect)rect
     {
        // Write your code here
     }
 * @endcode

For more details of documenting methods of a custom class you can have a look on my blog Function Documentation in Xcode.

Solution 5:

To get Xcode to show documentation for your classes, you must create a documentation set for your classes using a tool like Doxygen or HeaderDoc. After creating the documentation set, you must install it using Xcode's documentation preferences. Apple has an article on using Doxygen, but it covers Xcode 3, not 4.

Using Doxygen to Create Xcode Documentation Sets