I am at a loss! This is one of those nasty mistakes that happen only under certain conditions, but I cannot directly relate the conditions and results.
My application has paged UIScrollView, where each pageview comes from MyViewController, a subclass of UITableViewController. To minimize memory usage, I unload controllers that are currently not visible. Here is my "cleanup" method:
- (void) cleanViewControllers:(BOOL)all {
if (all) {
for (NSInteger i = 0; i < [viewControllers count]; i++)
[viewControllers replaceObjectAtIndex:i withObject:[NSNull null]];
}
else if ([viewControllers count] > 2) {
NSInteger i = pageControl.currentPage - 2;
if (i > -1) [viewControllers replaceObjectAtIndex:i withObject:[NSNull null]];
i = pageControl.currentPage + 2;
if (i < [viewControllers count]) [viewControllers replaceObjectAtIndex:i withObject:[NSNull null]];
}
}
This is the line that causes the application to crash:
viewControllers replaceObjectAtIndex:i withObject:[NSNull null]];
viewControllers is an NSMutableArray containing objects of type MyViewController. MyViewController has no custom properties, and its dealloc method contains nothing but a call to [super dealloc].
:
alt text http://a.imageshack.us/img831/3610/screenshot20100806at126.png
, , , . , , ScrollView, ( X) , , X, . !
, 4.0 iPad, iPod 1- , 3.1.3.