Possible Duplicate:
Does Objective-C guarantee the initialization of interface member data?
When I declare an object in the header (.h file) and do not assign any value to it. What will be it initial value?
@interface myObject: NSObject {
NSString *instanceObject;
}
- (id)init
{
NSLog(@"The value of object is: %@", instanceObject);
return [super init];
}
This will show:
The value of object is: (null)
Can I assume all objects will start with null=0x0 and never with garbage?
For Objects (like NSString*) yes, but for simple types like int and long u can’t assume its a 0 by default.
and note, that when u release an object it doesn’t become a nil by default, so if u send it something again later, U’ll get a crash in ur app
Edited spelling