如何配置Xcode放置'{'我想要它在生成的文件 [英] How can I configure Xcode to put '{' where I want it in generated files

查看:118
本文介绍了如何配置Xcode放置'{'我想要它在生成的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是程序员中的一个有争议的问题,但是当开发我喜欢我的IDE,以定位在方法/接口/控制声明下的开放的大括号,为了说明: -

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: -

这是Xcode如何自动生成带有{在结尾的骨架方法:

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

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

这是我喜欢布置我的代码我相信它被称为 Allman style ): -

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;
    }
}



我只是想知道是否有任何配置开关Xcode能够实现这种开发方式吗?当输入 if / else 语句时,它真的很讨厌,因为它倾向于自动完成 else 子句中的 {在行的末尾,只是看起来愚蠢,如果你喜欢与他们在下面开发。

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.

还是我不合理?是Objective-C应该遵守由Apple定义的标准吗?

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

推荐答案

看看:

XCode:调整自动生成的大括号的缩进?

Apple Xcode用户默认值

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

这应该至少可以解决if,for或while语句后的问题。

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

这篇关于如何配置Xcode放置'{'我想要它在生成的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆