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

前端 未结 4 966
無奈伤痛
無奈伤痛 2021-02-06 13:42

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 t

相关标签:
4条回答
  • 2021-02-06 14:23

    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 :(

    0 讨论(0)
  • 2021-02-06 14:25
        /**
         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

    0 讨论(0)
  • 2021-02-06 14:28

    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

    0 讨论(0)
  • 2021-02-06 14:32

    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 :

    0 讨论(0)
提交回复
热议问题