代理 必须实现和可实现@required 和@optional

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

@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];
    }