How do I add auto-complete comment in Xcode (Swift)?

青春壹個敷衍的年華 提交于 2019-12-03 13:49:14

问题


How can I add text to autocomplete like below, the "Tells the element to activate itself..." part,

This is what I have,

But the "This is a test" part doesn't show up in autocomplete,

Please do not link to other posts that cover how to write comments so that they would show up in the window that pops up with Option+Click, I'm well-aware of how to do that. My question is specifically around comments showing up in the auto-complete window.


回答1:


What you are trying to accomplish is unfortunately not possible anymore.

The reason is that the autocomplete popover does not show comments from class files but instead searches in a separate doc-set generated by Apple.

I added a more complete description here: https://stackoverflow.com/a/43982094/1415898




回答2:


try this, tested on xcode 9.3 - 9.4 beta and swift 4.1

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

and result :




回答3:


I have searched a lot and it seems that this feature does not support for self-created functions. all you have is just the popup info window for your functions :(




回答4:


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



来源:https://stackoverflow.com/questions/40517798/how-do-i-add-auto-complete-comment-in-xcode-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!