Question

I am a bit confused now why sometimes we call an instance method this way:

NSDate *now = [NSDate date];

double seconds = [now timeIntervalSince1970];

and sometimes we do it this way:

NSDate *later = [now dateByAddingTimeInterval:100000];

and why it gives me error if I used the second one this way:

double later = [now dateByAddingTimeInterval:100000];

??

Hello there.

At first, I wondered why you were working with the above line of code. But now I get it. You are posting this question in the wrong chapter/section of this forum.

It should be 14. More Messages.

[color=#004040]JR[/color]

Because “timeIntervalSince1970” is an instance method, which returns a variable of double type.

[quote=“raff7m”]I am a bit confused now why sometimes we call an instance method this way:

NSDate *now = [NSDate date];

double seconds = [now timeIntervalSince1970];

and sometimes we do it this way:

NSDate *later = [now dateByAddingTimeInterval:100000];

and why it gives me error if I used the second one this way:

double later = [now dateByAddingTimeInterval:100000];

??[/quote]