Releasing subviews
<p>I have a UIScrollView that has multiple pages of information that are added as subviews to the scrollView. Each subView's controller is stored in a NSMutableArray in the scrollViewController.</p>

<p>I have some memory leaks in the subviews, and I am trying to fix them by making sure that each subview controller's dealloc method is called. I'm doing that by releasing the view controllers from within the scrollView controller's dealloc method.</p>

<p>When I try to release the array after the subViews controllers are released, the application crashes.</p>

<p>Code follows... what am I doing wrong?</p>

<pre><code>- (void)dealloc {

// Loop through the array of subView controllers and release them
for ( int i = 0; i &lt; [viewControllers count]; i ++ ) {
 [[viewControllers objectAtIndex:i] release];
}

[viewControllers release];  // Crashes here unless I remove the loop above
[scrollView release];
[pageControl release];
[theKnot release];
[super dealloc];
</code></pre>

<p>}</p>
