代理 必须实现和可实现@required 和@optional
- 作者: 苏菲娅50382222
- 来源: 51数据库
- 2022-08-17
@protocol DaiLi <NSObject> //默认是必须实现的 //必须实现 @required - (void)finshTask; - (void)dontLate; //可选实现 @optional - (void)wearNeat; @end @property (nonatomic, weak) id < DaiLi > delegate; .m文件 if (_delegate && [_delegate respondsToSelector:@selector(DaiLi)]) { [_delegate DaiLi]; }
推荐阅读