Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickly view the type of a Swift variable in XCode

Is there any shortcut that will allow me to quickly view the type of any variable in Swift in XCode? Alt-Click returns "No Quick Help". Type inference is awesome, but makes life hard without tools such as these...

like image 200
Advecticity Avatar asked Oct 21 '14 17:10

Advecticity


People also ask

How to see variable values in Xcode?

See Variable Values in Code and the Variable Viewer When your app pauses at a breakpoint, hover over a variable in your source code to view its current value. If the variable is an image or other type that isn't expressible as text, click the Quick Look button at the upper-right to see a preview of the variable.

What is type in Swift?

In Swift, there are two kinds of types: named types and compound types. A named type is a type that can be given a particular name when it's defined. Named types include classes, structures, enumerations, and protocols. For example, instances of a user-defined class named MyClass have the type MyClass .


1 Answers

Either use Alt-click to display the declaration of the variable which displays the type at the top right like so:enter image description here Or use autocompletion to show you the type:enter image description here

like image 123
Ian Avatar answered Nov 12 '22 20:11

Ian