phil
phil

Reputation: 1003

why would this code crash with "attempt to access previously deallocated instance"?

Aren't i doing this the standard way? I see this format quite a bit and am not sure why my code eventually crashes and tells me I'm trying to access a previously deallocated instance.

Any help appreciated.

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {

    vcListGrades *listGradesViewController = [[vcListGrades alloc] initWithNibName:@"vcListGrades" bundle:nil];

    listGradesViewController.managedObjectContext = self.managedObjectContext;
    Course *sCourse = [_fetchedResultsController objectAtIndexPath:indexPath];
    [listGradesViewController setCourse: sCourse];

        [self.navigationController pushViewController:listGradesViewController animated:YES];   

    [listGradesViewController release];

}

Upvotes: 0

Views: 53

Answers (1)

El Developer
El Developer

Reputation: 3346

Are you sure the problem is with your view controller, I would much likely say the problem is with sCourse, be sure of the memory management you do of the property course in your vcListGrades class. The management of the UIViewController seems to be just fine.

Upvotes: 2

Related Questions