如何在Xcode(Swift)中添加自动完成注释?

时间:2016-11-09 23:37:13

标签: swift xcode documentation

如何在自动填充中添加文字,如下所示,"告诉元素激活自己..."部分,

enter image description here

这就是我所拥有的,

enter image description here

但是"这是一个测试"部分不会显示在自动填充中,

enter image description here

请不要链接到其他帖子,这些帖子涵盖了如何撰写评论,以便它们显示在弹出Option + Click的窗口中,我很清楚如何做到这一点。我的问题是关于在自动完成窗口中显示的评论。

4 个答案:

答案 0 :(得分:1)

遗憾的是,您正在努力实现的目标不再可能。

原因是自动填充弹出窗口不会显示来自类文件的注释,而是搜索Apple生成的单独文档集。

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

答案 1 :(得分: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)")
}

结果: enter image description here

答案 2 :(得分:0)

我搜索了很多,似乎此功能不支持自创功能。你所拥有的只是你的功能的弹出信息窗口:(

答案 3 :(得分:0)

    /**
     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