self->counter = [NSNumber numberWithFloat:0.0f];
uses direct access to an ivar. With self
, it is equal to counter = [NSNumber numberWithFloat:0.0f];
where counter
is an ivar. That is to say self->
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.