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.

modusCell
  • 13,151
  • 9
  • 53
  • 80
Ignat
  • 1,142
  • 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
  • 22,184
  • 15
  • 80
  • 118
  • 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