So I\'m trying to figure out how I can get my program to lose the .0 after an integer when I don\'t need the any decimal places.
@IBOutlet weak var numberOf
It is better to verify a size of Double
value before you convert it otherwise it could crash.
extension Double {
func toInt() -> Int? {
if self >= Double(Int.min) && self < Double(Int.max) {
return Int(self)
} else {
return nil
}
}
}
The crash is easy to demonstrate, just use Int(Double.greatestFiniteMagnitude)
.