Objective-c Kit Kat Kinky Tech –delegate Hook
Artifice refers to a skill and a product that is too kit and useless.
Requirements Description
In the actual programming process, we always have to customize some of the controls, in the process of customization, sometimes like to implement some of their own delegate method
// MYScrollView.m- (instancetype)init{ ... self.delegae = self; ...}- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ NSLog(@"%s 我被执行", __func__); ...}
It's OK to look at the code above, but what happens when our other objects want to implement delegate?
// ViewController.m- (void)viewDidLoad { ... scrollView.delegate = self; ...}- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ NSLog(@"%s 执行了ViewController里的方法,就不执行MYScrollView的方法了", __func__); ...}
Some students in the Viewcontroller method in the call Uiscrollview method, we do not know myscrollview own implementation of those delegate methods Ah, can only be forwarded each.
// ViewController.m- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ [(MYScrollView *)scrollView scrollViewDidScroll:scrollView]; ...}...
Objective-c Kit Kat Kinky Tech--delegate Hook