Assigning a value to self.button calls the synthesized setter method:
- (void)setButton:(UIButton *)button;
Because you added the "retain" attribute to your property declaration, the synthesized setter will automatically call "retain" on the object that is set. This ups the retain count of the object.
Calling "alloc" on UIButton also ups the object's retain count.
So doing self.button = [UIButton alloc] essentially will up your retain count by 2. That's why there's a potential leak.
You can fix this by doing either:
self.button = [[[UIButton alloc] initwithFrame : CGRectMake(10, 10, 20, 20)] autorelease];
or
UIButton *temp = [[UIButton alloc] initwithFrame : CGRectMake(10, 10, 20, 20)];
self.button = temp;
[temp release];
or
_button = [[UIButton alloc] initwithFrame : CGRectMake(10, 10, 20, 20)];