Nesting image sends


I’ve been thoroughly enjoying this book for roughly a week now. After plowing through chapter 21 and 22 I decided I should start anew from chapter 13 because I was really struggling implementing the new things I was learning properly. But re-reading chapter 14 I noticed something I couldn’t really answer myself:

This bit of code instantiates an NSDate at the address *now and then subsequently puts the return value of timeIntervalSince1970 in a double variable called seconds. Afterwards the pointer and therefore the object NSDate still lives.

NSDate *now = [NSDate date]; double seconds = [now timeIntervalSince1970];

But when nesting the message send no pointer for the NSDate is given, so doesn’t that mean that when the timeIntervalSince1970 method has been passed, the object will be dealocated?

If this were true, it would be a positive thing if you would only be needing an NSDate for a single method, but if you would be asking it more than one thing, like the example we’re working with in Chapter 14, wouldn’t this be a very pollutive and possibly demanding way of sending messages?

I’m wondering because that would of course be another reason to chose for either of these options, apart from the fact it might look cluttery and difficult to read.