Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

dot notation vs method which is better?

I'v was watching the Blog app tutorial today. (Modifying the Master Detail Template) at 10:58 it says that we can use either use dot notation or can be called as a method.

self.titlesArray.count;

or

[self.titlesArray count];

My question is what's the difference? and which one is better?

What is the difference?

3 Answers

Ravi Shankar
PLUS
Ravi Shankar
Courses Plus Student 7,823 Points

Generally dot notation are used for accessing properties and method notation for calling actions.

Check out the below link for more information.

http://stackoverflow.com/questions/1249392/style-dot-notation-vs-message-notation-in-objective-c-2-0

Matt Allen
Matt Allen
7,975 Points

Just to throw my two cents in. In the video Amit mentions that the method notation should be used for readonly properties. For example "count" is a readonly property hence the use of the method notation instead of dot.

Oh ok. Cool. That's good to know.

Thank you Ravi.