In the base.h It implement a delegate function
id<MADayViewDataSource> _dataSource;
@protocol MADayViewDataSource <NSObject>
- (NSArray *)dayView:(MADayView *)dayView eventsForDate:(NSDate *)date;
@end
In the 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];
}
In top Viewcontroller.h It implement the MADayViewDatasource delegate from base.h
:UIViewController<MADayViewDataSource> { }
In base.m, It implement that delegate function
- (NSArray *)dayView:(MADayView *)dayView eventsForDate:(NSDate *)startDate {
So, my understanding of the code is when the function inside the base.m is called
[self.datasource dayView:self eventsForDate:self.day];
The self.datasource
would call -(void)setDataSource <MADayViewDataSource>)dataSource {}
which return the _datasource....etc anyway, I am lost..
My question what's sequence of fucntion being called? How does the datasource from base relate to the array returning from the delegate function from the top viewcontroller?