Swift 2.0 Type Introspection

I’ve been at WWDC this week and it has been a whirlwind. I am feeling quite overwhelmed, overloaded, and oversaturated with newness, but to that effect I have something small to share about introspection in Swift 2.0. Pre Swift 2 you may recall some talk of a mirrorType mentioned both here in this video and in this blog post. This is accessible from things conforming to the Reflectable protocol using the function getMirror(). Although, this is still available in Swift-2, it is limited, and according to an Apple engineer i talked to, never really intended for public use. With Swift 2, though, we can just init a Mirror struct with an Any as below:

And there you have it, type introspection!