Initialization of controllers in a for loop - leaking problem ?
- by gotye
Hey,
I am creating a kinda gallery and for each gallery I created a view controller whose view is added to a scrollview (see code below) :
GalleryViewController *galViewController;
for (NSUInteger i = 0 ; i < [galleries count]; i++) {
galViewController = [[GalleryViewController alloc] init];
galViewController.record = [galleries objectAtIndex:i];
//galViewController.position = i;
galViewController.view.frame = CGRectMake(i%3*100,i/3*150,100,150);
[galViewController setDelegate:self];
[self.scrollView addSubview:galViewController.view];
//[galViewController release];
}
Is this code leaking ? I think so ... but the thing is that I don't know what to do with these controllers ... i can't release them (cause I got some code to use in the future like touches event) and I don't need to save them somewhere ...
Is this a problem to have this kind of code ?
Thks,
Gotye