Skip to content

一种利用消息链来实现view与viewcontroller或者Window之间的传值,省去了代理协议或者block传值的麻烦

Notifications You must be signed in to change notification settings

hunterxie/ResponderChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

ResponderChain

消息链

可以实现数据通过消息链传递 从而到达传值;

从而不在需要什么块函数 或者代理

比如说cell 传递给VC 可直接通过消息链传递

Cell -> VC -> window View - >View -> VC -> window

举例:

1、某个Cell的.m文件中点击事件触发

@implementation XLControlCell
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
-(void)awakeFromNib
{
[super awakeFromNib];
}
- (IBAction)mClickAll:(id)sender {
[self handAction:NSStringFromClass([self class]) withObject:@(1)];
}
@end

2、在使用该Cell的控制器ViewController下使用

-(BOOL)chainRouter:(NSString *)identifier withObject:(id)object
{
if ([identifier isEqualToString:@"XLControlCell"]) {
//dosomething .
}
return NO;
}

About

一种利用消息链来实现view与viewcontroller或者Window之间的传值,省去了代理协议或者block传值的麻烦

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages