Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

enter image description here

This is what I have,

enter image description here

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

enter image description here

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.

like image 929
treble_maker Avatar asked Nov 09 '16 23:11

treble_maker


People also ask

How do I use autocomplete in Xcode?

Go to Xcode > Preferences > Text Editing again. Quit out of Xcode and then relaunch Xcode. Now go to Code completion and check 'Suggest completions while typing'. Try typing library function or enum and enjoy!

How do I get suggestions in Xcode?

Press the escape key when auto-complete makes the first suggestion. This will display the list. Escape or control-comma will show the list, control-period will accept the current suggestion and (subsequently) rotate through suggestions, control-slash will move to the next placeholder argument that was inserted.

What does P mean in Xcode?

P: property (IIRC Xcode favors L/V for Swift, but you see P for ObjC properties)


2 Answers

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 : enter image description here

like image 87
Fardin Allahverdi Avatar answered Sep 30 '22 16:09

Fardin Allahverdi


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

like image 45
Delta Whiskey Avatar answered Sep 30 '22 15:09

Delta Whiskey