【问题标题】:How do I add auto-complete comment in Xcode (Swift)?如何在 Xcode (Swift) 中添加自动完成注释?
【发布时间】:2017-03-23 21:39:38
【问题描述】:

如何向自动完成添加文本,如下所示,“告诉元素激活自身...”部分,

这就是我所拥有的,

但是“这是一个测试”部分没有出现在自动完成中,

请不要链接到其他涉及如何编写 cmets 的帖子,以便它们显示在使用 Option+Click 弹出的窗口中,我很清楚如何做到这一点。我的问题是关于自动完成窗口中显示的 cmets。

【问题讨论】:

标签: swift xcode documentation


【解决方案1】:

试试这个,在 Xcode 9.3 - 9.4 beta 和 swift 4.1 上测试

/// this is printName func and will print your name
func printName(name: String){
   print("my name is \(name)")
}

和结果:

【讨论】:

  • ///三个cmets做的吗?或者// 两个在同一位置也可以工作?
【解决方案2】:
    /**
     Put comments just above the funcion using the Markdown format like this
    */
    func exampleFunction() {
        print("The comments above will show up in the auto complete popover.")
    }

Popover Example

Full explanation @ Hacking With Swift

【讨论】:

    【解决方案3】:

    不幸的是,你想要完成的事情已经不可能了。

    原因是自动完成弹出框不显示类文件中的 cmets,而是在 Apple 生成的单独文档集中搜索。

    我在这里添加了更完整的描述: https://stackoverflow.com/a/43982094/1415898

    【讨论】:

      【解决方案4】:

      搜了很多,貌似这个功能不支持自建功能。你所拥有的只是你的功能的弹出信息窗口:(

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-10
      • 2017-03-14
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多