Let me introduce: SwiftyAs. It’s a tiny little library to provide sort of the same functionality as as? from Swift in Objective-C. Let me explain…
In Swift, you can use the as? operator to safely cast a variable to another type (albeit Optional). If the actual type at runtime doesn’t match, Swift turns it into a nil, and otherwise you just get the variable as an optional.
Read more on blog.inferis.org