一、整理了objclean調(diào)查結(jié)果中多數(shù)人的代碼風(fēng)格,http://objclean.com/survey.php
1.function

2.property declare

3.variable declare

4.protocol

5.condition


二、使用Clang-Format
Clang-Format是一款Xcode的代碼格式化插件,github項(xiàng)目地址https://github.com/travisjeffery/ClangFormat-Xcode,安裝使用過程如下:
1.通過Package Manager搜索并安裝插件

2.在工程目錄下放置.clang-format的配置文件,可以自己調(diào)整相應(yīng)值,示例配置文件如下:
# 基礎(chǔ)樣式
BasedOnStyle: LLVM
# 縮進(jìn)寬度
IndentWidth: 4
# 圓括號(hào)的換行方式
BreakBeforeBraces: Attach
# 支持一行的if
AllowShortIfStatementsOnASingleLine: true
# switch的case縮進(jìn)
IndentCaseLabels: true
# 針對(duì)OC的block的縮進(jìn)寬度
ObjCBlockIndentWidth: 4
# 針對(duì)OC,屬性名后加空格
ObjCSpaceAfterProperty: true
# 每行字符的長度
ColumnLimit: 0
# 注釋對(duì)齊
AlignTrailingComments: true
# 括號(hào)后加空格
SpaceAfterCStyleCast: false
# 不在小括號(hào)里加空格
SpacesInParentheses: false
# 不在中括號(hào)里加空格
SpacesInSquareBrackets: false
3.安裝成功后會(huì)在xcode–>Edit里出現(xiàn)選項(xiàng)
