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.
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:
// TODO: Check for existence of files
// TODO: Refactor code for NSNotification
#pragma mark -
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)
// ??? 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
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.