What's the difference between dot syntax and square bracket syntax?

后端 未结 5 497
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 06:27

I am going through some walkthroughs fpr Objective-C and I got to many places where I raised my eyebrows. I would love to get them down.

  1. Is there a fundamen

5条回答
  •  鱼传尺愫
    2020-11-27 07:01

    1: Your terminology is incorrect. The dot operator is not "method calling", a different operation. It's just a different visual appearance for message sending. There's no difference between [x y] and x.y. The dot syntax can only take one argument though, as it's intended to be used only for property access.

    2: The static (compile-time) type of an object has no effect on its behavior at runtime. Your object is still an NSEnumerator even if you're calling it something else.

提交回复
热议问题