Objective-C tab settings and whitespace style

后端 未结 1 832
太阳男子
太阳男子 2021-02-14 00:31

Apple\'s Objective-C documentation, references, and generated code seem to be totally inconsistent with their coding style. I can not determine the \"preferred\" style (if one

1条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-14 00:49

    I found that I was constantly setting the generated projects to my own preferred style, so I edited the template files to my preferences (tabs for indent, braces on a line of their own). The files are here:

    /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/

    I select everything, get rid of all indentation with cmd-[ (as many times as the document needs) and do Edit->Format->re-indent. I have this hooked up to shift-cmd-[ for convenience.

    I've seen the differences in style for example code and project templates and just assumed it was due to the age of the files being different. I guess they have had different internal coding style guides which have changed.

    Here's the Google Obj-C style guide:

    http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml

    and another nice one from CocoaDevCentral:

    http://www.cocoadevcentral.com/articles/000082.php

    of if you really want to follow Apple rules, the Objective C programming guide has a bunch of code examples to take rules from.

    https://developer.apple.com/library/mac/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/

    0 讨论(0)
提交回复
热议问题