【问题标题】:Reformatting to have method parameters in a new line重新格式化以在新行中包含方法参数
【发布时间】:2013-04-29 22:36:38
【问题描述】:

Code->Style->Objective-C的偏好设置里有很多设置。我正在寻找合适的来重新格式化这行代码

SCPropertyDefinition *test = [SCPropertyDefinition definitionWithName:@"created_at" title:@"Tweeted At" type:SCPropertyTypeLabel];

转成这种格式

SCPropertyDefinition *test = [SCPropertyDefinition definitionWithName:@"created_at" 
                                                                title:@"Tweeted At" 
                                                                 type:SCPropertyTypeLabel];

(重点是让冒号缩进匹配)

我猜它应该在 Wrapping and Braces 选项卡中,但我还没有找到正确的设置。 感谢您的想法。

【问题讨论】:

    标签: objective-c coding-style appcode


    【解决方案1】:

    您要查找的设置是Wrapping and Braces | Method call arguments 设置为Chop down if long 并启用Align by colon。请注意,Method parameters 有单独的设置。

    【讨论】:

    • 这个选项似乎已从 AppCode 2 中删除。或已移动,但我找不到。我希望有一个热键可以在两种格式格式之间切换一行。
    • 不,它还在那里。您应该转到设置->代码样式-> Obj-C 查找“方法参数”并将“不换行”更改为“始终换行”或“如果长则切掉”
    • 这不再起作用了。我在 Appcode 3.3 中找不到任何对 Chop Down if Long 的引用。有其他选择吗?
    【解决方案2】:

    似乎从 App Code 2017.1(可能更早)开始,Swift 中不提供按冒号对齐的选项。你仍然可以告诉 App Code 砍掉一个很长的参数/参数列表:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-25
      • 2019-11-02
      • 2021-12-07
      • 1970-01-01
      • 1970-01-01
      • 2019-02-11
      • 2011-05-17
      • 2021-05-14
      相关资源
      最近更新 更多