Xcode FIXME and TODO

Tue, Dec 23

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:

//  BirdBookAppDelegate.m
//
// TODO: Check for existence of files
// TODO: Refactor code for NSNotification
#pragma mark -

// 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.

  // FIXME: Change memory mgmt handling in this block.
  // Create portrait window and content view (to hold other views)
  UIWindow *localPortraitWindow;

// ??? 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:

- (void) applicationDidFinishLaunching:(UIApplication *)application
{
  // ???: How does this work?
  [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
  ...
  ...
- (void) dealloc
{
  // !!!: Verify that all objects are accounted for
  [tabBarController release];
...

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.

6 comments

Very useful stuff. Must try when I come home …

by invictus_slo on Dec 30, 2008. Reply #

Neat trick. I work with a guy who uses the functions window all the time. For me, I very rarely, if ever, use it. I could see value in common marker tags for grepping a project, but for some reason I never latched on to looking at the function window for a single file.

by Damon Allison on Dec 31, 2008. Reply #

There is also // MARK:

by mick on Jan 19, 2009. Reply #

I just tried // MARK: and it has the exact same effect as #pragma mark. You can even use // MARK: with a dash to get the separator.

by Random Visitor on Feb 2, 2009. Reply #

This doesn’t seem to work in XCODE 4. Any suggestions about how to use it there?

by Bjorn on Sep 12, 2011. Reply #

It kind of seems to work in Xcode 4.
However the “// …” only work when it is outside of methods/functions

by Oscar on Dec 29, 2011. Reply #

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>