是否存在属性的自动初始化? [英] Is there automatic initialization for attributes?
本文介绍了是否存在属性的自动初始化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道属性是在对象初始化期间自动设置为nil
还是具有随机值?
I was wondering if attributes were automatically set to nil
during an object's initialization or they have random values?
推荐答案
如果这个问题指示了Objective-C,我想说的是在声明变量时应初始化变量的 all 值.
If this question is indicative of Objective-C, I'd say that you should initialize all values of a variable when you declare them.
在声明变量时显式初始化变量有两个好处:
Explicitly initializing variables when they're declared gives you two benefits:
- 变量的值没有任何歧义.
- 其他读取您的代码的可读性.
这篇关于是否存在属性的自动初始化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文