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

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>