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 trial
Eric Wolff
1,822 PointsWhy are some methods called with [ ] while you can use ( ) for others
I have been looking around online and I haven't found the answer to this question. Most of the time a method can be called using [ ] while other times I will get a compiler error and it turns out I need to call the method using ( ). Can someone explain why I would use one way over the other way?
2 Answers
Stone Preston
42,016 PointsObjective C methods are called using square brackets [ ] (or sometimes dot notation for example in setter/getter method calls). C functions (for instance the CGRectMake() function) must be called using parenthesis ( )
Eric Wolff
1,822 PointsOh that makes sense because Objective C is an extension of C.
Thanks Stone!