Objective-c:通过点表示法和方法使用属性之间的区别?
问题描述:
通过点表示法和通过发送消息获取和设置属性有什么区别?
What is the difference between getting and setting properties via dot notation and via sending message?
... = anObject.property;
... = [anObject property];
anObject.property = ...;
[anObject setProperty:...];
点符号只是消息发送的语法标记,代码编译完全相同或存在与 nil
处理,性能等有什么不同?
Is the dot notation only a syntactic suger for message sending and the code is compiled exactly the same or there are some differences with nil
handling, performance, etc?
答
点符号是否仅用于发送消息的语法糖,代码编译完全相同?
Is the dot notation only syntactic sugar for message sending and the code is compiled exactly the same?
是的,他们完全一样。