Difference between “.text” and “setText:”? [duplicate]

江枫思渺然 提交于 2019-12-05 20:53:54
dasblinkenlight

There is no difference in the inner workings. The first way requires the type of label to be such that the compiler could verify the presence of the property; the second way works even if the compiler does not know the exact type (i.e. when the type is an id).

The second syntax is the original one; the first syntax was added for convenience and readability. There are different schools of thought on the subject of using these syntaxes: some people will tell you not to use one syntax or the other, and provide very valid reasons for it. In the end, though, this is your choice: you should pick one syntax, and stay with. As long as you are consistent and your readers know of your preference, they should have no trouble reading and maintaining your code either way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!