BOOL的默认值 [英] Default value of BOOL
本文介绍了BOOL的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是Objective-C的一个 BOOL
变量的默认值?
What is the default value of a BOOL
variable in Objective-C?
推荐答案
有是的没有的默认值,如果你写
There is no default value if you write
-(void)somemethod {
BOOL x; // <--- no default value
据初始化为垃圾。
It is initialized to garbage.
然而,对于 BOOL
的伊娃的,它会被初始化为 NO
,作为整个实例用0填充在初始化
However, for a BOOL
ivar, it will be initialized to NO
, as the whole instance is filled with 0 on initialization.
(注意:当ARC启用时,当地的对象指针的永远是有一个默认值无
,但非对象的局部变量类型,如BOOL仍然初始化为垃圾。请参见局部变量设置为nil?(目标-C)。)
(Note: When ARC is enabled, local object pointers will always be have a default value nil
, but local variables of non-object types like BOOL are still initialized to garbage. See Local variables set to nil? (Objective-C).)
这篇关于BOOL的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文