This is because timeIntervalSinceNow expect NSTimeInterval , which is Double .
If you do:
let day_seconds = 86400
day_second - type Int, which is not expected. However, when entering the number itself:
let one_day_from_now = NSDate(timeIntervalSinceNow:86400)
implicit that you pass Double, because that is what the method expects, which is normal.
The solution can be used NSTimeInterval(day_seconds) or Double(day_seconds) , which is the same, or when you declare a constant, make sure it is doubled, for example:
let day_seconds = 86400.0
or
let day_seconds: Double = 86400
or
let day_seconds: NSTimeInterval = 86400
source share