Dot Syntax

We should mention an alternative syntax for sending accessor messages to an object called dot syntax:

/​/​ ​F​o​l​l​o​w​i​n​g​ ​t​w​o​ ​l​i​n​e​s​ ​a​r​e​ ​e​x​a​c​t​l​y​ ​e​q​u​i​v​a​l​e​n​t​
i​n​t​ ​v​a​l​u​e​ ​=​ ​[​i​t​e​m​ ​v​a​l​u​e​I​n​D​o​l​l​a​r​s​]​;​
i​n​t​ ​v​a​l​u​e​ ​=​ ​i​t​e​m​.​v​a​l​u​e​I​n​D​o​l​l​a​r​s​;​

/​/​ ​F​o​l​l​o​w​i​n​g​ ​t​w​o​ ​l​i​n​e​s​ ​a​r​e​ ​e​x​a​c​t​l​y​ ​e​q​u​i​v​a​l​e​n​t​
[​i​t​e​m​ ​s​e​t​V​a​l​u​e​I​n​D​o​l​l​a​r​s​:​5​]​;​
i​t​e​m​.​v​a​l​u​e​I​n​D​o​l​l​a​r​s​ ​=​ ​5​;​

We have reservations about Objective-C newcomers using dot syntax. We think it hides the fact that you are actually sending a message and can be confusing. Once you are comfortable with Objective-C, it is totally okay ...

Get iOS 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.