Objects and Pointers


I am a bit stumped. In the following code, why can I use double seconds = [now timeIntervalSince1970]; but I have to declare a pointer for later - NSDate *later = [now dateByAddingTimeInterval:100000];? Why can’t I just declare another double like so - double later = [now dateByAddingTimeInterval:100000];?

[code]#import <Foundation/Foundation.h>

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

@autoreleasepool {
    NSDate *now = [NSDate date];
    NSLog(@"the new date lives at %@", now);
    double seconds = [now timeIntervalSince1970];
    NSLog(@"It has been %f seconds since the start of 1970", seconds);
    NSDate *later = [now dateByAddingTimeInterval:100000];
    NSLog(@"In 100,000 seconds, it will be %@", later);
return 0;



You could add 100000 to your seconds variable to get a number of seconds without interacting with NSDate at all, but what would that give you? You’re trying to generate a date object that can tell you what the day will be in the future.


Why can’t I just create a “future” variable? Why do I have to create a pointer at all?