Showing enum options

I have for example this code:


var myAlert: UIAlertController = UIAlertController(title: "Title text ",
                                       message: "message", 
                                       preferredStyle: UIAlertControllerStyle. )


When I press the dot after UIAlertControllerStyle I would expect the options of this enumerator type. Instead I get a lot of other suggestions (also). Is there a quick way to only show the available options of this enum type?


NB: I have experience with Visual Studio. I'm quite new to Xcode (yet ...).

This is not precisely the answer to the question you asked, but instead of typing "UIAlertControllerStyle.", just type ".". The compiler know the type of the parameter, so you don't need the type name, and you get a better autocompletion experience.


Also, note that it's stylistically usual to omit the type name in Swift, whereas in C# you are required to have the type name for an enum case (when the enum is defined in a different scope). Generally in Swift, you let the compiler infer types whenever possible.

I did precisely that, press dot. However, it gives me not just the available enum options, but also a long list of other types. So that way I have to know what I'm looking for.

You said:


"When I press the dot after UIAlertControllerStyle…"


In that circumstance, with Xcode 7.3.1, I get a long list of stuff. If I omit the "UIAlertControllerStyle" and just type the dot:


preferredStyle: .


I get exactly 2 items in the completion list. Do you get a different result in this scenario?


The behavior in Xcode 8 beta 4 is a bit different. If I type the dot after "UIAlertControllerStyle", I get the choice of 8 items, including the 2 you're interested in. If I leave out the "UIAlertControllerStyle" and type just the dot, I get a choice of 4 things. (The other 2 are new-style color literal swatches, and it seems like a bug that they're there.)

I indeed did try only a dot yesterday, but then I got also the long list. I'm now not behind Xcode (daytime is &#$@ Windows ...) but will try again tonight. Thanks so far.

Showing enum options
 
 
Q