ork*_*ein 11 xcode objective-c clang-format
我有以下代码,例如:
[cardRegistrationVC setCancelBlock:^{
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
Run Code Online (Sandbox Code Playgroud)
当我对它应用clang格式时,它变成:
[cardRegistrationVC setCancelBlock:^{ [weakSelf.navigationController popViewControllerAnimated:YES]; }];
Run Code Online (Sandbox Code Playgroud)
如您所见,块内的代码出现在同一行.但我应该总是换上新的路线.
如何设置clang格式正确?我的以下设置文件:
BasedOnStyle: LLVM
AllowShortIfStatementsOnASingleLine: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
IndentCaseLabels: true
ColumnLimit: 120
ObjCSpaceAfterProperty: true
KeepEmptyLinesAtTheStartOfBlocks: true
PenaltyBreakString: 1000000
SpacesInContainerLiterals: false
Run Code Online (Sandbox Code Playgroud)
只需将其添加到设置文件(.clang-format)即可.
ObjCBlockIndentWidth: 4
Run Code Online (Sandbox Code Playgroud)
然后块就会这样.
[cardRegistrationVC setCancelBlock:^{
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
Run Code Online (Sandbox Code Playgroud)
希望能帮助你.
同时我想补充一下:
UseTab: Never
IndentWidth: 4
Run Code Online (Sandbox Code Playgroud)
最后我写了这样的块:
[cardRegistrationVC setCancelBlock:^{
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
Run Code Online (Sandbox Code Playgroud)
最后空行就可以了。或者您必须禁用列限制:
#ColumnLimit: 120
Run Code Online (Sandbox Code Playgroud)