使用 distantFuture 的实际例子是什么?

What is a practical example using distantFuture?

DispatchTime 和 (NS)Date 具有 属性 distantFuture,其中 "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.

我想不出或找不到实际需要使用它的示例。什么是好的用例?

例如,如果您想从未指定结束日期的日历中检索未来的事件。

在这种情况下,您可以将谓词的结束日期设置为 distantFuture

这是一个示例将返回哪些不明确的日期:

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"