DispatchTime and (NS)Date have the property distantFuture
, which "returns a time in the distant future."
Discussion:
You can pass this value to methods that schedule work to have the system wait indefinitely for a particular event to occur or condition to be met.
I can't think of or find an example where I would actually need to use this. What is a good use case?
For example if you want to retrieve future events from a calendar with an unspecified end date.
In this case you can set the end date of the predicate to distantFuture
.
Here's an example what unspecific dates will be returned:
let date = Date()
// current, here: "Sep 30, 2020 at 9:27 AM"
let distantPast = Date.distantPast
// "Jan 1, 1 at 12:53 AM"
let distantFuture = Date.distantFuture
// "Jan 1, 4001 at 1:00 AM"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.