Does init object set the object to nil?


#1

Hi

[code]-(instancetype)init
{
//Call the NSObject’s init method
self = [super init];

//Did it return something non-nil?
if(self){
    //Give voltage a starting value
    _voltage = 12;
}

//Return a pointer to the new object
return self;

}

[/code]

The book says according to NSObject’s init method,“Note that because BNRAppliance does not implement an init method, it will execute the init method defined in NSObject. When this happens, all the instance variables specific to BNRAppliance are zeroed out. Thus, the productName of a new instance of BNRAppliance will be nil, and voltage will be zero.”

Ok lets refer back to the code,

here self is equal to zero because it calls the super init method which is NSObject’s init method. Ergo, it is 0.
0 is false therefore will not run the code in the bracket.

but after writing a code to print out value of voltage is logs out 12. how is this possible?