iPhone OS 上的 NSDate dateByAddingTimeInterval 在哪里?

发布于 2024-08-08 16:14:32 字数 569 浏览 3 评论 0原文

问候!我一定是看到了一些东西。看看这个 摘自 iPhone 操作系统 参考库:

addTimeInterval:返回一个新的 NSDate 设置为给定数字的对象 相对于接收器的秒数。 (已弃用。此方法已被 dateByAddingTimeInterval: 取代。)

但是,在文档中或标头中都找不到它。如果我查看 Mac OS SDK,那么我就能找到它。

打字错误?毕竟继续使用 addTimeInterval: 吗?

Greetings! I must be seeing things. Look at this excerpt from the iPhone OS reference library:

addTimeInterval: Returns a new NSDate
object that is set to a given number
of seconds relative to the receiver.
(Deprecated. This method has been replaced by dateByAddingTimeInterval:.)

However, it is nowhere to be found in the docs, nor in the headers. If I look at the Mac OS SDK, then I find it.

Typo? Just keep using addTimeInterval: after all??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

妖妓 2024-08-15 16:14:32

这实际上是文档中的错误。 addTimeInterval: 在 Mac OS X 10.6 中已弃用,但在 iPhone OS 3.1.2 中并未弃用。

您可以查看 MacOS 和 iPhoneOS 中的 NSDate.h,您会发现差异。

iPhone OS 中的 NSDate.h

- (id)addTimeInterval:(NSTimeInterval)seconds;

和 Mac OS 10.6 中的 NSDate.h

- (id)addTimeInterval:(NSTimeInterval)seconds DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
- (id)dateByAddingTimeInterval:(NSTimeInterval)ti AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;

It's actually an error in the docs. addTimeInterval: is deprecated in Mac OS X 10.6 but not in iPhone OS 3.1.2.

You can look at the NSDate.h in MacOS and in iPhoneOS and you'll see the difference.

NSDate.h in iPhone OS

- (id)addTimeInterval:(NSTimeInterval)seconds;

and NSDate.h in Mac OS 10.6

- (id)addTimeInterval:(NSTimeInterval)seconds DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
- (id)dateByAddingTimeInterval:(NSTimeInterval)ti AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
我是有多爱你 2024-08-15 16:14:32

对我来说似乎是一个错字,因为我在我的系统上看到的内容与您相同。也许他们打算弃用所描述的方法,但在最后一刻将其删除,不正确的文本仍然存在。

Looks like a typo to me as I see the same thing on my system as you do. Perhaps they intended to deprecate the method as described but cut it at the last minute, with the incorrect text still in place.

浅笑依然 2024-08-15 16:14:32

addTimeInterval 现已在 iOS 4 中弃用。

addTimeInterval is now deprecated in iOS 4.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文