Search code examples
xcodemethodscoding-styleconventionsbrackets

Xcode 4 method braces "{" convention


I switched over to Xcode 4 while it was in beta, and I have mostly been editing existing code so haven't really considered this much until now...

Apple's file templates seem to have switched convention for coding methods. As an example, a pre-Xcode 4 dealloc method looked like this:

- (void)dealloc {
[super dealloc];
}

In Xcode 4, they now use this style:

- (void)dealloc
{
    [super dealloc];
}

As an avid perfectionist and irritable person, this has me quite miffed! I was brought up on the previous style in Xcode itself, and I'm now finding myself going through every template each time I create one to put the brackets back in the right place!

Please tell me this is a default option that I can change... or will I have to change my own coding style to match (or worse still, "learn to live with it" [shudder]!).


Solution

  • As far as I know, there's no default option you can change; however:

    If you are creating files, you can edit the files in /Developer/Library/Xcode/Templates to your desired coding style.

    As for the snippets in the editor, that are inserted when you type dealloc alone, and the like; these appear to come from /Developer/Library/Xcode/PrivatePlugins/IDECodeSnippetLibrary.plugin

    I wouldn't necessarily recommend editing the files in there; but it's an option.

    Edit: In order to prevent Xcode updates from breaking your perfectionized templates, you could probably chmod -w them, which should prevent updates from touching them; but it might cause updates to fail altogether.