Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you populate the Xcode 4 "Option+Click" popover?

Tags:

xcode4

In Xcode 4, if you option + click on a keyword, then the said keyword will appear in a popover with a bunch of descriptive information, like so:

enter image description here

However, when I option + click on my own method or variable, all I get is a link to the file in which the object was declared:

enter image description here

How is this done? Can I take advantage of this for my own code?

(I've noticed in some of the framework headers, that there is some sort of special comment syntax. Could that be related?)

like image 266
Moshe Avatar asked Apr 22 '11 00:04

Moshe


2 Answers

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:

like image 41
cbowns Avatar answered Oct 21 '22 23:10

cbowns


You must create your own "documentation set" for your API. Search Xcode's documentation for "Documentation Set Guide" and dig in. The "Documentation Sets" section of the guide specifically states that Quick Help uses this.

With a doc set in place, not only will this popup find the description but it will be available in the QuickHelp in the Utility pane as well as the documentation browser in the Organizer.

like image 64
Joshua Nozzi Avatar answered Oct 22 '22 00:10

Joshua Nozzi