why is UIWebViewDelegate assign instead of weak?

被刻印的时光 ゝ 提交于 2019-12-12 11:34:07

问题


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

UIWebView's delegate

@property(nonatomic, assign) id< UIWebViewDelegate > delegate;

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.


回答1:


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.



来源:https://stackoverflow.com/questions/36342075/why-is-uiwebviewdelegate-assign-instead-of-weak

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!