为什么此代码会因“尝试访问先前释放的实例”而崩溃?
我这不是按照标准方式做的吗?我经常看到这种格式,但不确定为什么我的代码最终崩溃并告诉我我正在尝试访问以前释放的实例。
任何帮助表示赞赏。
- (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];
}
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];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定问题出在您的视图控制器上吗?我很可能会说问题出在 sCourse 上,请确保您对 vcListGrades 类中的属性 course 进行的内存管理。 UIViewController 的管理似乎很好。
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.