iPhone OS上的NSDate dateByAddingTimeInterval? [英] Whither NSDate dateByAddingTimeInterval on iPhone OS?

查看:210
本文介绍了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;

这篇关于iPhone OS上的NSDate dateByAddingTimeInterval?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆