在base.h中实现委托函数
id<MADayViewDataSource> _dataSource;
@protocol MADayViewDataSource <NSObject>
- (NSArray *)dayView:(MADayView *)dayView eventsForDate:(NSDate *)date;
@end
在base.m
- (void)setDataSource:(id <MADayViewDataSource>)dataSource {
_dataSource = dataSource;
[self reloadData];
}
- (id <MADayViewDataSource>)dataSource {
return _dataSource;
}
- (void)reloadData {
NSArray *events = [self.dataSource dayView:self eventsForDate:self.day];
}
在顶部Viewcontroller.h中它实现了base.h的MADayViewDatasource委托
:UIViewController<MADayViewDataSource> { }
在base.m中,它实现了委托函数
- (NSArray *)dayView:(MADayView *)dayView eventsForDate:(NSDate *)startDate {
所以,我对代码的理解是 当base.m中的函数被调用时
[self.datasource dayView:self eventsForDate:self.day];
self.datasource
无论如何都会调用-(void)setDataSource <MADayViewDataSource>)dataSource {}
返回_datasource ....等等,我迷路了..
我的问题是什么序列的功能被称为?基数的数据源如何与从顶部viewcontroller从委托函数返回的数组相关?