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

把方法写成了简单的宏,打印可视化响应链。
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 *)touches withEvent:(UIEvent *)event {
  RESPONSE_CHAIN_PRINTING()
}

你可能感兴趣的:(重写touchBegan,打印可视化响应链)