Created
January 22, 2015 09:53
-
-
Save stevedoyle/4a3b46a040a7b5c05239 to your computer and use it in GitHub Desktop.
Working with NSNumber in Swift
This file contains 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
var targetDistance: NSNumber = 4000 | |
var completedDistance: NSNumber = 121.7 | |
var percentComplete: Float | |
// NSNumber can contain different types, so need to be explicit about the type of its value | |
// when using it in arithmetic | |
percentComplete = (completedDistance.floatValue / targetDistance.floatValue) * 100 | |
println(percentComplete) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment