I
I wrote a function which generates 6 UIView object automatically (with iteration), and I try then to insert each object in a NSMutableArray, but when I run it, it stop with warning (without a reference to the bug).
I dont know what is not conform in my logical steps.
here is my code.
-(void)initierScrollView
{
int i;
for (i=0; i<6; i++) {
UIImage *image = [UIImage imageNamed:@"back.png"];
UIImageView *bouton = [[UIImageView alloc] initWithImage:image];
[bouton setTag:i];
classementBoutons = [[NSMutableArray alloc] initWithCapacity:40];
[bouton setFrame:CGRectMake(10+62*i,10,62,55)];
[classementBoutons insertObject:bouton atIndex:i];
bouton.userInteractionEnabled = YES;
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
recognizer.delegate = self;
[bouton addGestureRecognizer:recognizer];
// NSLog(@"%@", classementBoutons.description);
[self addSubview:bouton];
}
}
thank you for your responses
Victor
You creating new NSMutableArray on each loop iteration.
Try to create it only once before loop.