I get an EXEC_BAD_ACCESS when executing the following steps:
STEP 1: Click on "Scores" button from a Main Menu: This Removes the Menu (UIView), and loads the Scores (UIView) which subsequently initiates the process of populating a UITableView with values. No problems here.
self.viewController4 = [[ScoresViewController alloc] initWithNibName:@"ScoresViewController" bundle:nil];
[window addSubview:viewController4.view];
[viewController.view removeFromSuperview];
NSLog(@"LOADING SCORES SCREEN");
STEP 2: Click on "menu" button from the Scores Screen: This Removes the Scores (UIView), and loads the Menu (UIView) again. No problems here.
self.viewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController" bundle:nil];
[window addSubview:viewController.view];
[viewController4.view removeFromSuperview];
NSLog(@"Loading MAIN MENU");
STEP 3: Click on the "Scores" button again from the Main Menu: Again, this Removes the Menu (UIView), and loads the Scores (UIView) which subsequently initiates the process of populating a UITableView with values. Problematic!
The application crashes before displaying the Score Screen (UIView). Using the debugger I traced the problem to the single line of code: cell.text = [self->theScoresArray objectAtIndex:indexPath.row]; appearing in the below routine:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [theTable dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.text = [self->theScoresArray objectAtIndex:indexPath.row];
return cell;
}
Could this be a problem with the indexPath object not being properly released the first time? Any insight would be helpful. Thanks for your valuable time.