Different results coming out of an init method than those expected. Why does this happen and how can
- by Mark Reid
When I run this method the two properties I have are set to (NULL) when I try and access them outside of the if statement. But they are set to 0 and NO if I check them inside the for loop.
-(id) init
{
NSLog(@"Jumping into the init method!");
if (self = [super init]) {
NSLog(@"Running the init method extras");
accumulator = 0;
NSLog(@"self.accumulator is %g", accumulator);
decimal = NO;
}
NSLog(@"Calc after init is: %@ and %@", self.accumulator, self.decimal);
return self;
}
Any suggestions as to why what comes out is different from what's done in the for loop?