3.为什么代理要用weak?代理的delegate和dataSource有什么区别?block和代理的区别?

整个《面试题》都是对2017年6月iOS招人心得(附面试题)的整理。

1.为什么代理要用weak?

   防止循环引用。例如View有一个协议,需要一个代理实现回调。一个Controller添加这个View,并且遵守协议,成为View的代理。如果不用week,用strong,Controller ->View -> delegate -> Controller,就循环引用了。

2.代理的delegate和dataSource有什么区别?

   delegate偏重于与用户交互的回调,有那些方法可以供我使用,例如UITableviewDelegate;dataSource偏重于数据的回调,view里面有什么东西,属性都是什么,例如UITableviewDatasource;

3.block和代理的区别?

   iOS block和代理的区别

你可能感兴趣的:(3.为什么代理要用weak?代理的delegate和dataSource有什么区别?block和代理的区别?)