I suddenly found that UIKit use weak
attribute instead of assign
in 9.3, it may already changed for a long time but I didn't notice that, feeling shamed.
@property(nullable,nonatomic,weak) id<UIScrollViewDelegate> delegate;
I noticed that because of a question. In the old days, we need set the delegate of UIScrollView
or UITableView
's delegate to nil in dealloc
method in case of crashing.
Now since SDK 9.3 has use weak
attribute for delegate
, I think if we build our apps using the newest SDK and deployment to any devices which system version are above iOS5 (weak attribute is involved at iOS5), we don't need to set the delegate to nil in dealloc
method.
However in the question I mentioned above, I have left a comment: "I'm curious to know if it would crash when you use the newest SDK to build and deploy to devices which are below iOS 9. Can you have a try? " and the answer is "Yes, the base SDK is "Latest iOS (iOS 9.3)". And it still crash if I doesn't set delegate to nil in dealloc method. ". I'm confused.
My question is if we build with 9.3 SDK and deploy to the device which system version is below 9.3 (I mean the SDK which use assign
rather than weak
attribute), is the delegate weak
?
Hmm there is another question, if we build with 9.3 SDK, can we deploy to devices which system version is below iOS 5.0 (says 4.3, it don't support weak attribute) ?