Error with dateByAddingTimeInterval


#1

Not sure if there is a problem with the book (or if Xcode has been updated since)
When I try to do the very first example, I get an error/warning. I think it’s easier to display with a screenshot.
Now, if I change from

to

I have zero problems.

Also makes me wonder, how come the time is off with 2 hours (or 7200 seconds)?
The log says it’s 12:17, when the clock is actually 14:17.

Thanks for reading


#2

dateByAddingTimeInterval is an instance method, I believe you are trying to use it as a class method. Look at the code on page 87 again, it uses the instance “now”, not the class NSDate as the object receiving that message. dateWithTimeIntervalSinceNow, however, is a class method, and you are using it properly.

I think the clock offset is probably a local time vs GMT kind of thing.