Xcode FIXME and TODO

Mon, Oct 27

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:

1
2
3
4
5
//  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:

1
2
3
4
5
6
7
8
9
10
11
- (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

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 !!!

by xTeo on Feb 10, 2009. Reply #

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.

by AliGator on Mar 7, 2009. Reply #

Nice tip about the // MARK: tag.

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

by XCode Shark on Jan 22, 2010. Reply #

I’m not familiar with any custom coding tags, however, would be an interesting option…

by John Muchow on Jan 22, 2010. Reply #

thank a lot ,USEFUL tips!!

by jhaoheng on Jun 8, 2012. Reply #

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…

by Andrew Robinson on Nov 8, 2012. Reply #

Leave a Comment