内存访问错误? [英] memory bad access?

查看:76
本文介绍了内存访问错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这句话怎么会给我不好的访问权限?

How can this statement ever give me bad access?

myWebView = [[NewsWebViewController alloc] initWithNibName:@"NewsWebViewController" bundle:nil];
[[self.view.superview superview] addSubview:myWebView.view];

 if(myWebView!=nil) {
    [myWebView release];
    myWebView = nil;
}

我已经通过仪器运行了它,每次都崩溃了. myWebView是我的头文件中的一个ivar.

Ive ran it through instruments and it crashes every time. myWebView is an ivar in my header file.

有什么想法吗?非常感谢

Any thoughts? Many thanks

朱尔斯

推荐答案

好的,这是实际问题.当我删除webview时,它被解除了分配,但是我没有将其委托设置为nil.因此,webViewDidFinishLoading等正在尝试访问它,并给了我错误的访问权限.

ok here is the actual issue. When I removed the webview it gets dealloc'd but I didnt set its delegate to nil. Therefore webViewDidFinishLoading etc was trying to access it and giving me bad access.

感谢大家的投入.

这篇关于内存访问错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆