I'm experiencing a weird problem. I have a for loop, inside the loop there is a switch statement. The counter in the for loop is a pointer that points to the beginning of a primitive array, it increments itself till it finds a "terminator number". The array pointed is used to build a view, each elements represent a subview to put in the view. Here is the code:
for (self.composizione; *composizione>kFine; composizione++) {
int c=(int)*composizione;
NSLog(@"%d",c);
switch (c) {
case kForchettaPesce: case kForchettaNormale:
{
NSString *imagePath;
imagePath=[[NSString alloc]initWithFormat:@"%@/%d.png",[[NSBundle mainBundle]resourcePath],c];
UIImage *image=[[UIImage alloc]initWithContentsOfFile:imagePath];
[imagePath release];
NSLog(@"pippo");
UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
imageView.image=image;
[image release];
[self.view addSubview:imageView];
[imageView release];
break;
}
default:
break;
}
NSLog(@"%d",(int)*composizione);
}
Debugging it I've found out that works perfectly untill it tries to add the subview. It seems to stay stucked in the loop and the log shows always the same datas in an infinite cycle. If I delete the -addSubview method I have no problem, the log statement shows what I expect to see. What am I doing wrong? Regards, Andrea