Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a newb to cocoa programming and looking around in various open source code online I see things like:

#pragma mark global variable declaration

and I was wondering what the meaning of "pragma mark" is in that is it any different than a // or /* (comment) is it used throughout the program, and is there a commonly used methodology to it, or is it more or less a way for programmers to organize and collect their code for themselves (and others if the case may be) to use later?

I found this article:

and it is pretty helpful, but I just needed to clarify again if it's more or less used by the coder or used by XCode?


share|improve this question
Isn't this a question for Stack Overflow? – kiamlaluno May 15 '11 at 23:25
I wasn't sure. At first I thought so, but then I was considering that it may be something that's more of a "developer preference" type thing. – Zac Brown May 15 '11 at 23:28
This is fine here. – user8 May 15 '11 at 23:33
up vote 7 down vote accepted

pragma mark is used by xcode to organize your code by creating as drop down list of methods contained within the scope of the pragma mark.

share|improve this answer
excellent clarification! that's a very helpful feature. are there any "standard" methods of using it or is it just up to the developer? – Zac Brown May 15 '11 at 23:26
@Zac Not a lot of standard methods, but in Xcode 4 if you use #pragma mark - My Cool Section, the hyphen right there will make Xcode display a horizontal line in the menu, under which will be (in this example) My Cool Section. – Matthew Frederick May 15 '11 at 23:50
wow, that's pretty cool. I'll play around with it and I bet it's really helpful. after I've achieved more rep I'll come back and vote this answer up :-) – Zac Brown May 15 '11 at 23:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.