Nesting message sends
Message sends can be nested. For instance, to find out the number of seconds since the start of 1970, you could write your code this way:
NSDate *now = [NSDate date]; double seconds = [now timeIntervalSince1970]; NSLog(@"It has been %f seconds since the start of 1970", seconds);
Or you could nest the two message sends like this:
double seconds = [[NSDate date] timeIntervalSince1970]; NSLog(@"It has been %f seconds since the start of ...
Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.