n8blog
distraction in action

Like my work? Check out HexaLex, my game for iPhone & iPod Touch. It's similar to Scrabble, but played with hexagonal tiles. http://www.hexalex.com

If you download code from Apple you’re likely to see a bunch of lines like

#pragma mark FooBar-related functions
#pragma mark -

A pragma is a directive to the compiler that’s not part of the program itself. According to wikipedia, the term pragma is an abbreviation of pragmatic. There are pragmas for various things like branch prediction hints and such, but I never knew what to make of the “mark” pragma. I figured maybe it placed a comment in the assembly output to help you debug or something. Well thankfully Colin Wheeler posted a blog entry on just this subject. It turns out that pragma mark isn’t for the compiler at all — it’s for XCode!

XCode makes a pop-up list of functions and methods in your code to make it easier to find things, but sometimes that list can get very long. If you put #pragma mark - in your code, XCode will insert a horizontal separator in the list. If you write some text instead of the hyphen then that text will be inserted in the list. I’ll refer you once more to Colin’s post if you want to see what this looks like.

It’s a nice tip — thanks Colin!

  • Share/Bookmark

  Comments:

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

Please type this word with the letters reversed: live

Like my work? Check out HexaLex, my game for iPhone & iPod Touch. It's similar to Scrabble, but played with hexagonal tiles. http://www.hexalex.com