把方法写成了简单的宏,打印可视化响应链。
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()
}
网友评论