Xcode FIXME and TODO

In a previous post I introduced how to use #pragma mark to help navigate source files within Xcode. There are several additional tags that can be used within a source file to call out specific code or content.

// TODO:

This tag is handy for reminding yourself of things that you need to get back to at some point. I generally into these statements at the top of the source file within the main comment block to remind me of features I need to update or add. Here is how this might look in a code block:

// FIXME:

Another useful tag, this one calls out code that needs to be re-visited for changes/fixes. The code below shows one example of how this looks, and the figure above shows how this appears inside the Functions menu in Xcode.

// ??? and /// !!!:

These two tags I don’t use as frequently as those above, however, they do have there place. I use the former when I’m not sure how something works and I need to come back another time to dig a little deeper. The later is nice if you need a reminder of a significant task to perform, for example, verifying that all objects are released inside the dealloc() method. The following code shows both tags inside a source file:

The tags for the above would look as follows inside the Functions menu:

Once you get accustomed to using #pragma and one or more of the tags above, it becomes second nature to insert these as you write code. And trust me, these are of great help as the size and complexity of your projects grows.

  1. This is great !!
    I always though this was missing to xCode ;) I guess I still have a lot to learn .

    I use tag like this a lot in doxygen , and it generate a Todo page .

    is there something like that where those tags are all shown in one place ? I guess I can use the Project find and it does a good job .
    but a Todos page/view would be a nice feature to xCode.

    Thanks for this very useful tips !!!

  2. Note that you can also use “// MARK: xxx” instead of “#pragma mark xxx”

    This makes your code portable (whereas #pragma directives are compiler-dependant) and make it possible to insert “// MARK: foo” at the end of a code line without having to go to a fresh new line to insert the mark.

  3. Nice tip about the // MARK: tag.

    Is there any way to add custom tags (Like “FIX:” or “LATER:”)?

  4. A quick addition, you can also use #warning if you want a more visible, tougher reminder.
    I.e.:

    #warning This selector will not fire unless…

Comments are closed.