美文网首页
重写touchBegan,打印可视化响应链

重写touchBegan,打印可视化响应链

作者: 闻道刘 | 来源:发表于2017-06-01 15:23 被阅读15次

把方法写成了简单的宏,打印可视化响应链。
mark一下。


#define RESPONSE_CHAIN_PRINTING() \
UIResponder * next = [self nextResponder];\
NSMutableString * prefix = @"-".mutableCopy;\
NSLog(@"%@", [self class]);\
while (next != nil) {\
    NSLog(@"%@%@", prefix, [next class]);\
    [prefix appendString: @"-"];\
    next = [next nextResponder];\
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  RESPONSE_CHAIN_PRINTING()
}

相关文章

网友评论

      本文标题:重写touchBegan,打印可视化响应链

      本文链接:https://www.haomeiwen.com/subject/cekefxtx.html