什么时候在实例变量前面做下划线? [英] When do you make an underscore in front of an instance variable?
本文介绍了什么时候在实例变量前面做下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
How does an underscore in front of a variable in a cocoa objective-c class work?
我在Apple看到这个,在UIPickerView.h中:
I've seen this at Apple, inside UIPickerView.h:
id<UIPickerViewDataSource> _dataSource;
为什么会有下划线?它有特殊的意义吗?一个公约我必须知道吗?
why's that underscore there? Does it have a special meaning? A Convention I must know about?
推荐答案
很多人使用私有变量来区分私有变量和公共变量
A lot of people use this for private variables, to differentiate between private variables and public variables within an object.
这是一种完全可选的工作方式。
It is a completely optional way of working.
这篇关于什么时候在实例变量前面做下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文