Initialization of controllers in a for loop - leaking problem ?
Posted
by gotye
on Stack Overflow
See other posts from Stack Overflow
or by gotye
Published on 2010-03-20T14:30:17Z
Indexed on
2010/03/20
14:31 UTC
Read the original article
Hit count: 428
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
© Stack Overflow or respective owner