当我们定义枚举类型时,我们可能需要为每种情况添加一些注释。
我知道在Obj-C中我们可以有这样的注释语法:
enum Example
{
Example1, ///< Comments for Example1.
Example2, ///< Comments for Example2.
Example3. ///< Comments for Example3.
}我的问题是:如何在swift中做到这一点?
发布于 2018-08-02 02:23:32
您可以使用双星来显示摘要中的注释:
enum Example {
/** Comments for Example1. (with stars) */
case example1
/// Comments for Example2. (with three slash)
case example2
/// Comments for Example3. (with three slash)
case example3
}这是一个reference
发布于 2018-08-02 02:02:05
有点不清楚你的问题是什么-添加"//“将使该行上的其余代码成为注释。所以你应该这样做:
enum Example
{
Example1, // Comments for Example1.
Example2, // Comments for Example2.
Example3. // Comments for Example3.
}或者,您可以像使用obj-c一样来执行此操作。两者都应该工作得很好。
https://stackoverflow.com/questions/51639566
复制相似问题