#pragma mark Equivalent in XCode 6

Remember #pragma mark? In Objective-C code it’s a lovely way to make your methods a little easier to find in the Xcode source navigator. While Swift doesn’t have Objective-C’s preprocessor support (and good riddance) I’ve come across a few magic comments that, if conservatively used, can make your code a lot more readable: MARK, TODO, and FIXME.

The effect of MARK, TODO, and FIXME in Xcode 6

The effect of MARK, TODO, and FIXME in Xcode 6

MARK

Use // MARK: Section Description to break your code up into logical sections. I use MARK breaks to (among other things) group together methods that implement a particular interface or share some related function (e.g. touchesBegan, touchesMoved, &c.). Start your section description (the bit after MARK: with a single dash to set the code off with a separator.

TODO

Use // TODO: Message to your future self! to indicate places in your code that still need work.

FIXME

As near as I can tell, FIXME works exactly like TODO. Take your pick, I guess — but try and stay consistent. I exclusively use TODO, but that’s just a personal preference.

Leave a Reply

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