-1
可能重複:
Does Objective-C guarantee the initialization of interface member data?Objective-c中的所有對象都以null(0x0)開頭嗎?
當我聲明在頭(h文件)的對象,並且不任何值分配給它。初始值是什麼?
@interface myObject: NSObject {
NSString *instanceObject;
}
- (id)init
{
NSLog(@"The value of object is: %@", instanceObject);
return [super init];
}
這將顯示:
The value of object is: (null)
我可以假設所有對象將開始與null=0x0
從不與垃圾?
這是不正確的;無論類型如何,_all_ ivars都被'alloc'初始化爲合適的0值。 – 2012-02-14 18:52:08