I just started chapter 17, when the first example of code I tried returns an error when I try to use ‘dateByAddingTimeInterval’. It’s like Xcode does not recognize this or something. Does anyone know why? I’m using Xcode 6. Thanks!

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
@autoreleasepool {

    // Create three NSDate objects
    NSDate *now=[NSDate date];
    NSDate *tomorrow=[NSDate dateByAddingTimeInterval:24.0*3600.0];
    NSDate *yesterday=[NSDate dateByAddingTimeInterval:-24.0*3600.0];
    // Create an array containing all three
    NSArray *dateList=@[now, tomorrow, yesterday];
return 0;



dateByAddingTimeInterval: is not a class method; it is an instance method.

For more details, see: NSDate Class Reference