Ok, I am confused!
I used to use -> whenever I accessed my instance objects, but now I see that after I set them in my application:didFinishLaunching like this:
self->counter = [NSNumber numberWithFloat:0.0f];
Down the road I got thrown out with an Exception, checked my debugger and saw that counter was pointing to a <non objective c object>
I changed the line to :
self.counter = [NSNumber numberWithFloat:0.0f];
And now I see in the debugger that I have yes another variable.
So, what is happening here?
self->counter = [NSNumber numberWithFloat:0.0f];uses direct access to an ivar. Withself, it is equal tocounter = [NSNumber numberWithFloat:0.0f];wherecounteris an ivar. That is to sayself->is a redundant scope qualification within an instance method.self.counter = [NSNumber numberWithFloat:0.0f];is syntactic sugar for[self setCounter:[NSNumber numberWithFloat:0.0f]];. Specifically, the declaration dynamically messages the object’s setter for counter. Although there are exceptions, you should favor using the accessor when not in a partially constructed/destructed state.