Reputation: 193
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.
Upvotes: 7
Views: 2776
Reputation: 500
Update on Xcode 14.3.1 it's now possible to add comment on autocompletion popover just adding a single line comment to the property like in example below
extension CGFloat {
/// A size of 0 points
static let sizing0x = CGFloat(0)
/// A size of 2 points
static let sizing0xHalf = CGFloat(2)
/// A size of 1 points
static let sizing0xQuarter = CGFloat(1)
/// A size of 4 points
static let sizing1x = CGFloat(4)
/// A size of 6 points
static let sizing1xHalf = CGFloat(6)
/// A size of 8 points
static let sizing2x = CGFloat(8)
/// A size of 12 points
static let sizing3x = CGFloat(12)
/// A size of 14 points
static let sizing3xHalf = CGFloat(14)
/// A size of 16 points
static let sizing4x = CGFloat(16)
}
now you can see in the screenshot below the comment while typing.
Upvotes: 1
Reputation: 317
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)")
}
Upvotes: 6
Reputation: 41
/**
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.")
}
Full explanation @ Hacking With Swift
Upvotes: 2
Reputation: 2063
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
Upvotes: 1
Reputation: 625
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 :(
Upvotes: 0