Whither NSDate dateByAddingTimeInterval on iPhone OS?

datetime, iphone, nsdate

Solution

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;

Problem

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??

Original source