Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I configure Xcode to put '{' where I want it in generated files

I know this is a fairly contentious issue amongst programmers, but when developing I like my IDE to position the opening curly bracket underneath the method/interface/control declaration, for illustrative purposes: -

This is how Xcode automatically generates skeleton methods with the { at the end: -

-(void) isTrue:(BOOL)input {
    if(input) {
        return YES;
    }
    else {
        return NO;
    }
}

This is how I like to lay out my code (which I believe is called the Allman style): -

-(void) isTrue:(BOOL)input 
{
    if(input) 
    {
        return YES;
    }
    else 
    {
        return NO;
    }
}

I'm just wondering if there's any configuration switch in Xcode to enable this style of development? It's really annoying when typing out if/else statements as it tends to auto-complete the else clause with the { at the end of the line which just looks silly if you like developing with them underneath.

Or am I being unreasonable? Is Objective-C supposed to adhere to a standard defined by Apple?

like image 733
djhworld Avatar asked Apr 10 '10 13:04

djhworld


1 Answers

Take a look at:

Xcode: Adjusting indentation of auto-generated braces?

Apple Xcode User Defaults

XCCodeSenseFormattingOptions = {
  BlockSeparator = "\\n";
  PreMethodDeclSpacing = "";
};

This should at least solve your problem after if, for, or while statements.

like image 119
WhirlWind Avatar answered Sep 20 '22 15:09

WhirlWind