5

What is the difference in accessing an objects properties or methods via foo.property to [foo property]?

Rick
  • 197
  • 1
  • 3
  • 15

2 Answers2

10

Nothing! Dot-notation is "syntactic sugar" introduced in Objective-C 2.0. In fact, the compiler converts foo.property to [foo property] during compile-time, so they compile to exactly the same thing.

It's simply a matter of which you prefer.

iKenndac
  • 18,730
  • 3
  • 35
  • 51
1

At compile time they're treated the same, but one benefit of using dot notation to handle properties is that while coding, after placing the "." code completion/code window will only show valid properties as suggestions whereas using brackets will show all methods.

Vadoff
  • 9,219
  • 6
  • 43
  • 39