Xcode 8 How to Show Description of Function While Typing

Xcode 8 auto-generated quick help documentation

This refers to Xcode 8 (and later) feature, where you can select a method like this:

func foo(bar: Int) -> String { ... }

... and then press +option+/ (or choose “Structure” » “Add documentation” from Xcode's “Editor” menu) and it will generate the following comments template for you:

/// <#Description#>
///
/// - parameter bar: <#bar description#>
///
/// - returns: <#return value description#>

It just facilitates the writing of documentation for Quick Help.


Note, while this behavior has changed a bit over time, Xcode can be particular about where the cursor must be when you attempt to do this. For example, the cursor has to be somewhere in the function name, foo in my above example, for this to work. Or just double click on the function name and then press +option+/


You asked whether this feature replaces tools like Jazzy.

No, it doesn’t replace Jazzy or similar tools. Amongst other things, Jazzy creates stand-alone HTML documentation from this inline documentation. So, it is simply a question of whether you need these stand-alone outputs from Jazzy for any reason. If so, use Jazzy (or similar tool) in conjunction with this integrated documentation. If not (i.e., you are only looking for documentation from within the Xcode IDE), then Jazzy is not needed.

How to include Doxygen method description in Xcode's autocomplete popup?

Good news everyone! Xcode 5 now has built-in support for DOxygen style comments. So, you can comment your methods like this:

/*!
* Provides an NSManagedObjectContext singleton appropriate for use on the main
* thread. If the context doesn't already exist it is created and bound to the
* persistent store coordinator for the application, otherwise the existing
* singleton contextis returned.
* \param someParameter You can even add parameters
* \returns The a shared NSManagedObjectContext for the application.
*/
+ (NSManagedObjectContext *)sharedContext;


Inline help will look like this:

inline help

Quick help will look like this:

quick help

And sidebar help will look like this:

sidebar help

Here's a handy code snippet you can add the your Xcode Code Snippet library to make method documentation simple:

/**
<#description#>
@param <#parameter#>
@returns <#retval#>
@exception <#throws#>
*/

doxygen code snippet

Now, you can just type "doxy" and poof! You have your doxygen template.

Toggle iOS 8 predictive text while typing

As of now (Xcode 6.0.1) there is no documented feature to enable/disable predictive bar on the go. But there is a way to toggle it programmatically. I also tried some other methods (eg. setNeedsLayout on input view) but this is the only one that works.

[textfield resignFirstResponder];
[textfield becomeFirstResponder];

It even works in an animation block but awful animations, don't use it :]

XCode Show Function Parameters Hotkey

Just discovered Option + Escape by browsing through the XCode Preferences Hotkeys section. It actually lists the parameter info in a tooltip (no other hotkey I've seen so far does this!), but isn't quite as friendly as Visual Studio's Ctrl+Shift+Space function. For instance, the text selection cursor (caret) must be on the function name (not on a parameter to that function).

Having explored the XCode hotkeys exhaustively, I'm going to assume that this is the best it gets in XCode.

Is there a way to jump to a specific method in Xcode?

I think this is what you're looking for:

Type ctrl-6 to activate the "Show Document Items" in the "Jump Bar". Then start typing part of the method you are looking for to narrow the results.

Example:

To jump straight to - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

Type ctrl-6, type "cellFor", arrow down so the method is highlighted, and press Enter. The Editor will jump right to that method.

Incidentally, you can use ctrl-1, ctrl-2, ctrl-3, etc. to access the different sections of the "Jump Bar".

How can I make auto-complete display a list in Xcode

Press the escape key when auto-complete makes the first suggestion. This will display the list.



Related Topics



Leave a reply



Submit