Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialagreatdaytocode
24,757 Pointsdot 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
Courses Plus Student 7,823 PointsGenerally 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
7,975 PointsJust 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.
agreatdaytocode
24,757 PointsOh ok. Cool. That's good to know.
agreatdaytocode
24,757 PointsThank you Ravi.