2

I have written Pragma Mark after @implementation ViewController in .m file.

But Pragma Mark is not display in .m file whenever i have not synthesized any property. Why Xcode is restricting me for doing this ?

Even if other Pragma Marks is displayed. But the Pragma Mark written after @implementation ViewController is not displayed.

If i synthesized any single property after @implementation ViewController, then the Pragma Mark is displayed. I am not getting all this fus.

@implementation ViewController


# pragma  mark View Life cycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
6
  • Can you show us the #pragma code snipped where the error occurs? What version of Xcode? Commented Jan 10, 2013 at 11:51
  • @DavidRönnqvist : i am using Xcode 4.5.1 :) Commented Jan 10, 2013 at 12:05
  • I have updated my answer...have a look :) Commented Jan 10, 2013 at 12:14
  • 1
    It is indeed missing. You should file a bug Commented Jan 10, 2013 at 12:22
  • Appears to be a bug in Xcode 4.5/4.6. First pragma mark never shows. Worked fine in earlier versions. Commented Apr 8, 2013 at 19:58

3 Answers 3

3

Use in this way:

@implementation MainViewController
{}
#pragma YES
#pragma mark - Second -
Sign up to request clarification or add additional context in comments.

7 Comments

You don't need to have multiple #pragmas like that. Any - surrounded by whitespace is turned into a separator e.g. #pragma mark - First -. I'm sure it's a stylistic choice but I find the multiline version painful on the eyes
i use separator to distinguish similar kind of methods like all ioactions, all tableview delgates, all textfield delegate to find it with ease. :)
@Anoop : Write #pragma mark exact after " implementation MainViewController " Then check it.
Ok... Now I got your problem, for the first method you cant set pragma mark.
Now check the answer...a little bit of tweak.
|
-1

Its may be an Xcode version Problem.

Because in Xcode 4.2 it shows proper.

1 Comment

Not really i have used Xcode3, 3.1, 3.2, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5... everywere it worked fine.
-1

i think it is working for Xcode 4.2. I am not able to do in Xcode 4.5 if i am not writing any synthesized property.

@Implementation ViewController

#pragma mark -
#pragma mark Init

this code doesn't display Init. when i am writing below code in Xcode 4.5

@Implementation ViewController

@synthesize txtlabel;

#pragma mark -
#pragma mark Init

above code displays Init, So i think its Xcode problem.

Thanks, Sagar.

1 Comment

Just to let you know you can abbreviate that to #pragma mark - Init

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.