Under iOS 5, I encounter the following problem : the following code is called on a controller everytime a new product is picked in the application. It displays a bullet list of features in the controller's view.
Every bullet is an image that is added at the right place (in front of the corresponding text).
Now, the problem is that sometimes, apparently randomly, some bullets are not removed from the previous bullet lists, altough I remove it from its superview at the beginning of the methods.
- (void) loadProduct{
for (UIView * bullet in bullets){
bullet.hidden = YES;
[bullet removeFromSuperview];
}
[bullets removeAllObjects];
[self.view setNeedsDisplay];
......here some stuff ......
for (int i=0;i< numberOfFeatures;i++)
{
UIImageView * bullet = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bullet.png"]];
bullet.frame =CGRectMake(someFloatValue ,
someOtherFloatValue,
6,
6);
[self.view addSubview:bullet];
[bullets addObject:bullet];
[bullet release];
}
}
bullets
is an NSMutableArray, a property of the controller.
Am I doing something wrong here?