Documenting Code in XCode

When we talk about documenting a code, apparently, it doesn’t mean adding a few comments on the methods of your implementation files. It’s definitely more than that. Is it that critical to document the code? Whether you’re working on your own, or you are a part of a team, good comments on classes, methods will provide everyone good detail on why and what that code is for.

A good application is not just about writing a clean code. No matter how well-written the code is, if there is no detailed documentation created along with it, chances of trouble arising in future is higher. The worst decision, you might make during the application creation period, would be to skip the comments, even if you are the sole developer or working in a team.

Xcode 5 and Document Support

That said, let us start with the support that Xcode provides to document your code. A small addition was mentioned during the Xcode 5 and iOS 7 announcements that most people might have missed: HeaderDoc and Doxygen. Most of you, as a developer, might have seen that the in-built framework classes and functions are described in the Quick look panels of the XCode. It is possible to have the same effect in your code, also, using the correct format for commenting.

Xcode parses HeaderDoc-style comments behind the scenes to, automatically, present your documentation in quick look panels.

The simplest commenting technique you must have used for sure is:

Using these, your documentation can be displayed in three different places:
1. Quick Help Inspector — In the Utilities panel.
2. Help Popup — That is displayed when you press the Option key and click on the name of method, class or property.
3. In the code-completion popup.

There are three possible ways to mark a documentation area when writing code in Objective-C. To learn more, download the full article here.


Sudeep KS

iOS and Swift Developer, RapidValue Solutions