Xcode - 使用 #pragma 标记
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1230904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode - Using #pragma mark
提问by mk12
I'm pretty sure this isn't a duplicate. Do you use #pragma mark? I've seen multiple ways, which is correct?
我很确定这不是重复的。你使用#pragma 标记吗?我见过多种方法,哪个是正确的?
#pragma mark -
#pragma mark === Actions ===
#pragma mark -
#pragma mark -
#pragma mark === Actions ===
#pragma mark - === Actions ===
#pragma mark Actions
What is the way you do it? How do you suggest dividing it up? What do you normally name your sections, for say, a view controller?
你是怎么做的?你建议怎么分?你通常给你的部分起什么名字,比如说,一个视图控制器?
回答by Louis Gerbarg
There is no "Correct" way, it is annotation, so how you use it is a coding style issue.
没有“正确”的方式,它是注释,所以你如何使用它是一个编码风格问题。
Having said that, I do:
话虽如此,我这样做:
#pragma mark -
#pragma mark Actions
Because that causes the popup menu in the Xcode editor group the title and the methods inside of the same divider.
因为这会导致 Xcode 编辑器中的弹出菜单将标题和方法分组在同一分隔符内。
回答by Denis Kozhukhov
if use like this
如果像这样使用
#pragma mark -
#pragma mark Actions
or this
或这个
#pragma mark - Actions
xcode will add one separator and bold text line Actions.
xcode 将添加一个分隔符和粗体文本行操作。
BUTif you add one more space after minus - xcode will create two separators one by one...
但是,如果您在减号之后再添加一个空格 - xcode 将一一创建两个分隔符...
#pragma mark -SPACEHERE
#pragma mark Actions
:)
:)