Objective-c:通过点表示法和方法使用属性之间的区别? [英] Objective-c: Difference between using properties via dot notation and methods?

查看:102
本文介绍了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?

是的,他们完全一样。

这篇关于Objective-c:通过点表示法和方法使用属性之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆