Mar*_*eon 118 xcode comments swift
在Swift中编写注释的目的是什么:
// MARK: This is a comment
Run Code Online (Sandbox Code Playgroud)
当你也可以这样做:
// This is a comment
Run Code Online (Sandbox Code Playgroud)
什么是// MARK
实现?
nhg*_*rif 209
的// MARK:
和// MARK: -
在夫特功能相同的语法#pragma mark
和#pragma mark -
在Objective-C的语法.
使用此语法(加号// TODO:
和// FIXME:
)时,您可以获得一些额外信息以显示在快速跳转栏中.
考虑以下几行源代码:
// MARK: A mark comment lives here.
func isPrime(_ value: UInt) -> Bool { return true }
Run Code Online (Sandbox Code Playgroud)
作为参考,快速跳转栏位于Xcode的顶部:
它主要用于帮助在文件中快速导航.
请注意,破折号(// MARK: -
)会显示一条漂亮的分隔线.考虑这个MARK
评论:
// MARK: - A mark comment lives here.
Run Code Online (Sandbox Code Playgroud)
该菜单中粗体选项正上方的深灰色分隔线来自破折号.
此外,我们可以在没有评论的情况下实现此分隔线,只需在破折号后面没有任何文字:
// MARK: -
Run Code Online (Sandbox Code Playgroud)
如上所述,// TODO:
评论也会出现在这里.
// MARK: - Prime functions
func isPrime(_ value: UInt) -> Bool {
// TODO: Actually implement the logic for this method
return true
}
func nthPrime(_ value: UInt) -> Int {
// FIXME: Returns incorrect values for some arguments
return 2
}
Run Code Online (Sandbox Code Playgroud)
单击快速跳转栏中的任意一行将直接转到源代码中的该行.
归档时间: |
|
查看次数: |
40042 次 |
最近记录: |