iPhone OS上的NSDate dateByAddingTimeInterval?

问题描述:

问候!我一定要看东西看看这个摘录自 iPhone 操作系统参考库:

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


addTimeInterval:返回一个新的NSDate
对象,该对象设置为相对于接收方的给定数量
秒。
(已弃用,此方法已替换为 dateByAddingTimeInterval:。)

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:.)

但是,它在文档和标题中都找不到。如果我查看Mac OS SDK,那么那么我找到了。

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?只要继续使用 addTimeInterval:毕竟

Typo? Just keep using addTimeInterval: after all??

这实际上是文档中的错误。在Mac OS X 10.6中不推荐使用 addTimeInterval:,但不能在iPhone OS 3.1.2中使用。

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.

您可以在MacOS和iPhoneOS中查看NSDate.h,您会看到差异。

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

iPhone OS中的NSDate.h

NSDate.h in iPhone OS

- (id)addTimeInterval:(NSTimeInterval)seconds;

和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;