简体   繁体   中英

why is UIWebViewDelegate assign instead of weak?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM