What is a #pragma mark?

Featured Image

One of many features in Xcode that developers forgot to use is #pragma mark directives. What is a #pragma mark? #pragma marks are simple directives that help us better organize our implementation code.

When you are using #pragma mark directives in implementation code, you are in one way adding titles for one or more segments of your code in Functions Menu. This is very useful feature, because in the end, your code (your list of your method definitions) looks neater and more organized. For example, if you put #pragma mark Private methods in your implementation code right above -(void) initUI{ } method, then the Functions Menu (in the navigation bar) will show Private methods for that definition and for any other definition you define or group together with -(void) initUI{ } method.

If you have problem with #pragma mark appearance (sections are not in array as you define), ensure that Sort List Alphabetically is not checked in the Code Sense preference settings. While this feature may be less necessary in smaller applications, when you have application with classes with more the ten method definitions, it’s a very good idea to use #pragma mark directives.


  1. I hate to break this to you, but your PHP coding in XCode editor is terrible. I’ve never before seen such poorly written PHP coding in XCode editor.

  2. Hi Ivan,

    I wait to adjust the micro volume of iOS device, but I don’t found any way yet.

    Can you give me your advice, the solution to fix that problem.

    Thank you,

  3. You really did not answer the question posed by your headline. Back to Google for me…

  4. If you do:

    #pragma mark –

    You can draw a line in your functions list to further organize your sections of code!

  5. One thing to note, if in your general preferences for XCode you checked to ’sort alphabetically’ it will screw up all your pragma notation in the pull down. I struggled trying to figure out why none of my pragma looked like yours … and that was the reason.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.