Created
June 12, 2014 03:22
-
-
Save debreuil/b8ec22d8e2a28e1aa1c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to you safely convert an AnyObject with a number value into a Double? | |
let anyDouble:AnyObject = 6.41 | |
if let xx = anyDouble as? NSNumber { | |
println( Double(xx)) // prints 6.41 | |
} | |
// will throw an error if the conversion fails! | |
let casted = Double(anyDouble as NSNumber) // 6.41 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment