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:

 ​ ​ ​ ​N​S​D​a​t​e​ ​*​n​o​w​ ​=​ ​[​N​S​D​a​t​e​ ​d​a​t​e​]​;​
 ​ ​ ​ ​d​o​u​b​l​e​ ​s​e​c​o​n​d​s​ ​=​ ​[​n​o​w​ ​t​i​m​e​I​n​t​e​r​v​a​l​S​i​n​c​e​1​9​7​0​]​;​
 ​ ​ ​ ​N​S​L​o​g​(​@​"​I​t​ ​h​a​s​ ​b​e​e​n​ ​%​f​ ​s​e​c​o​n​d​s​ ​s​i​n​c​e​ ​t​h​e​ ​s​t​a​r​t​ ​o​f​ ​1​9​7​0​"​,​ ​s​e​c​o​n​d​s​)​;​

Or you could nest the two message sends like this:

 ​ ​ ​ ​d​o​u​b​l​e​ ​s​e​c​o​n​d​s​ ​=​ ​[​[​N​S​D​a​t​e​ ​d​a​t​e​]​ ​t​i​m​e​I​n​t​e​r​v​a​l​S​i​n​c​e​1​9​7​0​]​;​ ​ ​ ​ ​N​S​L​o​g​(​@​"​I​t​ ​h​a​s​ ​b​e​e​n​ ​%​f​ ​s​e​c​o​n​d​s​ ​s​i​n​c​e​ ​t​h​e​ ​s​t​a​r​t​ ​o​f​ ...

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.