修复swizzle方法里面的bug
您好,
您好,这个是项目里面通过swizzle替换后的方法,现在这个方法里面有问题,想通过jspatch来修复,目前jspatch支持修改swizzle替换的方法吗?
-
(void)custom_sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event {
if (![SnailPrefrense sharedSnailPrefrense].isNoClickVoice && !self.isNoVoice) { NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"SnailMenu.mp3" withExtension:nil]; if (self.isGood) { fileURL = [[NSBundle mainBundle] URLForResource:@"SnailGood.mp3" withExtension:nil]; }if (!(self.isGood && self.isSelected)) { if (fileURL != nil) { SystemSoundID theSoundID; OSStatus error = AudioServicesCreateSystemSoundID((__bridge CFURLRef)fileURL, &theSoundID); if (error == kAudioServicesNoError){ AudioServicesPlaySystemSoundWithCompletion(theSoundID, ^{ AudioServicesDisposeSystemSoundID(theSoundID); }); }else { NSLog(@"Failed to create sound "); } } }}
// 是否小于设定的时间间隔 BOOL needSendAction = (NSDate.date.timeIntervalSince1970 - self.custom_acceptEventTime >= self.custom_acceptEventInterval); // 更新上一次点击时间戳 if (self.custom_acceptEventInterval > 0) { self.custom_acceptEventTime = NSDate.date.timeIntervalSince1970; } // 两次点击的时间间隔小于设定的时间间隔时,才执行响应事件 if (needSendAction) {
[self custom_sendAction:action to:target forEvent:event];} }
-
(void)load { Method systemMethod = class_getInstanceMethod(self, @selector(sendAction:to:forEvent:)); SEL sysSEL = @selector(sendAction:to:forEvent:); Method customMethod = class_getInstanceMethod(self, @selector(custom_sendAction:to:forEvent:)); SEL customSEL = @selector(custom_sendAction:to:forEvent:); BOOL didAddMethod = class_addMethod(self, sysSEL, method_getImplementation(customMethod), method_getTypeEncoding(customMethod)); if (didAddMethod) { class_replaceMethod(self, customSEL, method_getImplementation(systemMethod), method_getTypeEncoding(systemMethod)); }else{ method_exchangeImplementations(systemMethod, customMethod); } }
-
(void)custom_sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event { if (![SnailPrefrense sharedSnailPrefrense].isNoClickVoice && !self.isNoVoice) { NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"SnailMenu.mp3" withExtension:nil]; if (self.isGood) { fileURL = [[NSBundle mainBundle] URLForResource:@"SnailGood.mp3" withExtension:nil]; }
if (!(self.isGood && self.isSelected)) { if (fileURL != nil) { SystemSoundID theSoundID; OSStatus error = AudioServicesCreateSystemSoundID((__bridge CFURLRef)fileURL, &theSoundID); if (error == kAudioServicesNoError){ AudioServicesPlaySystemSoundWithCompletion(theSoundID, ^{ AudioServicesDisposeSystemSoundID(theSoundID); }); }else { NSLog(@"Failed to create sound "); } } }}
BOOL needSendAction = (NSDate.date.timeIntervalSince1970 - self.custom_acceptEventTime >= self.custom_acceptEventInterval); if (self.custom_acceptEventInterval > 0) { self.custom_acceptEventTime = NSDate.date.timeIntervalSince1970; } if (needSendAction) {
[self custom_sendAction:action to:target forEvent:event];} }
支持的