我目前正在调试我的应用程序,并且遇到了正在执行 segue 的问题,但我终其一生都无法弄清楚它是从哪里调用的。
我想知道是否可以添加一个断点,以便应用程序暂停并显示调用它的行?
我尝试添加一个符号断点,但无法正常工作。
为 UIViewController 创建类别并将其添加到其中:
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(prepareForSegue:sender;
SEL swizzledSelector = @selector(yd_prepareForSegue:sender;
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
}
- (void)yd_prepareForSegueUIStoryboardSegue *)segue senderid)sender {
[self yd_prepareForSegue:segue sender:sender];
NSLog(@"prepareForSegue From: %@", self);
}
关于ios - 如何为所有推送序列创建符号断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34593984/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |