- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
基金会Date
struct 提供了 Date.addingTimeInterval(_:)
和 Date.advanced(by:)
这看起来在功能上是相同的,但显然是不同的方法。它们之间实际上有区别还是它们最终相同?
查看文档,advanced(by:)
缺少任何东西,而且 addingTimeInterval(_:)
只说
The value to add, in seconds.
advanced(by:)
完全失踪。剧情变厚了!
最佳答案
.addingTimeInterval(_:)
是一个长期存在的方法,来自 ObjC NSDate。 .advanced(by:)
存在以匹配 Swift 中的 Strideable 一致性。 Date 同样具有 Stride 类型别名。
也就是说,Date 实际上并不符合 Strideable,and this has been discussed and generally rejected .
Strideable 伪一致性似乎已添加为 a large merge from Xcode 11.4 的一部分在名为 Schedulers+Date
的扩展中这似乎是Combine(不是开源的)的一部分。我在论坛上没有看到任何讨论,except for a note that it broke existing code .变更说明:
// Date cannot conform to Strideable per rdar://35158274
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension Date /* : Strideable */ {
我的预感是在 Combine 内部的某个地方,有 Date 到 Strideable 的追溯一致性。您只需提出要求即可获得相同的结果:
extension Date: Strideable {}
感觉 Swift stdlib 团队接受了 Date 不应该是 Strideable(我同意这个推理,因为它会引起很多常见的日期错误),但是 Apple 的其他一些团队想要它并且无论如何将钩子(Hook)放入 stdlib,没有放入一致性。
关于swift - Date.addingTimeInterval(_ :) and Date. advanced(by :)?)有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66321489/
今天,我在 Windows 10 的“程序和功能”列表中看到了 2 个不同版本的 ARC,因此我选择卸载旧版本,因为我需要一些空间。在卸载结束时,它们都消失了! 所以,我从 https://insta
我刚买了一台更强大的电脑,安装了 composer 并想继续我的项目,但是当我使用 gii 时,它给了我这个错误。 我该如何解决?为什么我得到它?谢谢你。 最佳答案 解决了。自 2.0.13 起,类名
1、介绍 这是我的《Advanced .Net Debugging》这个系列的第十一篇文章,也是这个系列的最后一篇了。我已经把原书的前八章内容全部写完了,本来打算继续写第九章和第十章的内容,后
一、介绍 这是我的《Advanced .Net Debugging》这个系列的第十篇文章。这篇文章的内容是原书的第三部分的【高级主题】的第八章【事后调试】。前面几篇文章,我们介绍了很多工具,可以
一、介绍 这是我的《 Advanced .Net Debugging》这个系列的第八篇文章。这篇文章的内容是原书的第二部分的【调试实战】的第六章【同步】。我们经常写一些多线程的应用程序,写的多
一、介绍 这是我的《 Advanced .Net Debugging》这个系列的第九篇文章。这篇文章的内容是原书的第二部分的【调试实战】的第七章【互用性】。互用性包含两个方面,第一个方面就是托
一、简介 这是我的《Advanced .Net Debugging》这个系列的第七篇文章。这篇文章的内容是原书的第二部分的【调试实战】的第五章,这一章主要讲的是从根本上认识托管堆和垃圾回收。软件
一、简介 这是我的《 Advanced .Net Debugging》这个系列的第六篇文章。这篇文章的内容是原书的第二部分的【调试实战】的第四章。这章主要讲的是程序集加载器,比如:CLR 加载
一、简介 我曾看到过许多开发人员使用错误的工具来分析问题,更有甚者,有些人连任何工具都没有使用。他们采取的分析方法通常包括:输出更多的调试信息,或者做一
一、简介 我曾看到过许多开发人员使用错误的工具来分析问题,更有甚者,有些人连任何工具都没有使用。他们采取的分析方法通常包括:输出更多的调试信息,或者做一
一、简介 我曾看到过许多开发人员使用错误的工具来分析问题,更有甚者,有些人连任何工具都没有使用。他们采取的分析方法通常包括:输出更多的调试信息,或者做一
我是 yii2 的新手,当我使用 从存档中提取 yii2 高级内容时《基本应用模板》、《带有高级应用模板的Yii 2》当我在服务器上上传时,它显示空白页面。 我检查了 yii2 basic 它工作正常
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 6 年前。 Improve this ques
如果我遗漏了任何重要的细节,我想提前道歉。 我正在尝试执行升级,在安装新版本之前应删除以前版本的软件(和所有组件)。 我会尽量避免让您厌烦细节,并说如果您进行“典型”安装,一切都会按计划进行。如果您选
您好,我正在尝试创建一个存储整数或字符串元素的通用列表迭代器。我正在尝试测试它调用 IteratorG advance(IteratorG it, int n) 函数的情况,该函数采用在列表 it 中
我想知道是否有任何可能的方法,使 MySQL 查询可以动态搜索 WHERE 子句中的任何内容。 例如,如果查询是 Select * from table where item = 'Dell Opti
我正在使用 PayPal Advanced,并使用用户定义的字段 USER1 - USER10 发送一些交易数据,这将帮助我在通过 Silent Post 请求返回时识别它。有谁知道这些 USERx
这个问题在这里已经有了答案: How to use "distanceTo", "advancedBy" to handle String in Xcode7 beta6 (2 个答案) 关闭 7
请告诉我如何提前获得 transactionHash? // I have these tx opts: var txOpts = { "to":"0x345cA3e014Aaf5dcA48805
我正在尝试使用 Eloquent 创建类似的东西。但是,我在使用 or 子句时遇到了麻烦。 SELECT * FROM table WHERE column1 = 1 AND column2 = 2
我是一名优秀的程序员,十分优秀!