小编Sto*_*one的帖子

对象可能在被释放后被修改

我正在开发一个关于iPhone的项目.我现在从另一个UIViewController启动一个新的UIViewController,然后在它们之间切换.这是我的代码.

iGreenAppDelegate *delegate = [UIApplication sharedApplication].delegate;
if(checkInViewController) {
    [checkInViewController release];
    checkInViewController = nil;
}
checkInViewController = [[CheckInViewController alloc] initWithCheckpoint:checkpoint];

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[delegate window] cache:YES];
[[delegate rootTabBarController].view removeFromSuperview];
[[delegate window] addSubview:checkInViewController.view];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

问题是我第二次启动UIViewController,我想释放它以避免导致内存泄漏.调试器显示

iGreen(916,0x3f60348c)malloc:对象0x130350的错误:释放对象的校验和不正确 - 对象可能在被释放后被修改.在malloc_error_break中设置断点以进行调试

这很奇怪,因为其他部分中的类似代码不会返回此类错误.此外,我尝试自动释放,但程序将立即崩溃,调试器说我正在修改最终的图层.

我一直在研究这个问题一整夜,并且仍然对此感到困惑.

memory-management autorelease ios

16
推荐指数
2
解决办法
4万
查看次数

标签 统计

autorelease ×1

ios ×1

memory-management ×1