为什么UIWebViewDelegate分配而不是弱? [英] why is UIWebViewDelegate assign instead of weak?

查看:65
本文介绍了为什么UIWebViewDelegate分配而不是弱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,除了UIWebView之外,整个UIKit/Foundation框架中的所有代表都是弱者.

Normally all delegates throughout the UIKit/Foundation frameworks are weak except UIWebView.

我很感兴趣,因为当您忘记取消UIWebView的ViewController时取消委托时,这在我的应用程序中导致了几次崩溃.通常,您不会期望这样的事情,因此可能有特定的原因默认情况下未将其设置为弱.

I am interested because this has caused a crash several time in my application when you forgot to nil out delegate while dismissing the UIWebView's ViewController. Normally you don't expect something like this, so there might be specific reason why this isn't set to weak by default.

推荐答案

假设如果UIWebViewDelegate定义为WEAK,则在ARC中它将自动 nil 委托的引用.所以UIWebViewDelegate标记为ASSIGN,因为如果未使用ARC编译该类,则必须注意将其设置为nil.

Suppose if the UIWebViewDelegate defined as WEAK then in ARC it will automatically nil the reference of delegate. So UIWebViewDelegate marked as ASSIGN because if the class is not compiled with ARC then we have to take care of set it as nil.

这篇关于为什么UIWebViewDelegate分配而不是弱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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