在这样的界面中:
@interface MyClass : NSObject
{
bool PlainOldBool;
}
@end
...PlainOldBool
是否自动初始化为 false,或者是否有必要使用 init 方法显式地执行此操作?
最佳答案
是的(unless your false
is not 0)。默认的 +alloc
/+allocWithZone:
方法将自动清零所有 ivar。
- It initializes all other instance variables to zero (or to the equivalent type for zero, such as
nil
,NULL
, and0.0
).
关于objective-c - Objective-C 是否保证接口(interface)成员数据的初始化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2533209/