0

They both do the same thing, return the value of an object's property called property. So, what is the difference other than syntax? Same thing also happens with arrays,

[[numberArray objectAtIndex:indexInt] integerValue]  

is the same as

((NSNumber*)numberArray[indexInt]).integerValue

At least it has been the same so far.

modus
  • 12,683
  • 9
  • 52
  • 78
Ignat
  • 1,106
  • 1
  • 12
  • 22

1 Answers1

2

There is absolutely no difference between using the dot notation or the square bracket messaging syntax. - with the caveat that you can send any message to id, but you can't get or set any property of id through dot syntax

Woodstock
  • 21,230
  • 15
  • 76
  • 114
  • 2
    That's almost true, with the caveat that you can send any message to `id`, but you can't get or set any property of `id` through dot syntax (As the OP's example shows, you have to cast explicitly to use dot syntax.) – ahruss Aug 08 '14 at 21:02