What is preferred in Objective-c dot notation or square bracket notation?

后端 未结 3 1353
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 07:03

I\'m reading a book - Big Nerd Ranch iOS Programming. It says that dot notation is not recommended as it obfuscates code. I am simultaneously watching a Stanford Course for

3条回答
  •  长情又很酷
    2020-12-14 07:29

    I know this is an old post but I would like to add a more modern answer.

    With the release of swift and the impending demise of our favorite language, the preference should lean towards dot notation. All iOS frameworks have updated their API to favor dot notation (preferring readonly properties in a header to getters). This makes the eventual translation towards swift more fluid.

    To be clear, prefer properties for instances where you are exposing getters and/or setters. Luckily Xcode's modern objective-c migration tool will do most of this for you.

提交回复
热议问题