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]!).
I've never been able to get to grips with Xcode indentation. Instead I've ended up with a separate script that calls uncrustify (for ObjC) or indent (for plain C) to clean up the code before each commit. That way my coding style (the only sensible one, naturally) is consistently (fanatically?) enforced at all times.
This also catches other typical Xcode annoyances like trailing whitespace, which a reasonable code editor would strip at save time.
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.
I set up this github repo, to share the fixed template files, which fix your issue.
精彩评论