There are several methods for determine an object's type at debug or compile time.
If the variable's type is explicitly declared, just look for it:
let test: [String] = ["Chicago", "New York", "Oregon", "Tampa"]
Here, test
is clearly marked as a [String]
(a Swift array of String
s).
If the variable's type is implicitly inferred, we can get some information by ⌥ Option+clicking.
let test = ["Chicago", "New York", "Oregon", "Tampa"]

Here, we can see test
's type is [String]
.
We can print the object's type using dynamicType
:
let test = ["Chicago", "New York", "Oregon", "Tampa"]
println(test.dynamicType)
Prints:
Swift.Array<Swift.String>
We can also see our variable in the variable's view:

Here, we can see the variable's type clearly in the parenthesis: [String]
Also, at a break point, we can ask the debugger about the variable:
(lldb) po test
["Chicago", "New York", "Oregon", "Tampa"]
(lldb) po test.dynamicType
Swift.Array<Swift.String>