2017-03-13 12:47:33.978 JJYSPlusPlus[9734:5104425] -[WYPlaceholderTextView removeObserver:]: unrecognized selector sent to instance 0x7ffb4e293e00
(lldb)
+ (void)load {
// Swizzle dealoc to remove observer when current object is deallocated.
Class classToSwizzle = [UITextView class];
// NSString *className = NSStringFromClass(classToSwizzle);
SEL deallocSelector = sel_registerName("dealloc");
__block void (*originalDealloc)(__unsafe_unretained id, SEL) = NULL;
id newDealloc = ^(__unsafe_unretained id objSelf) {
[objSelf removeObserver:self];
if (originalDealloc == NULL) {
struct objc_super superInfo = {
.receiver = objSelf,
.super_class = class_getSuperclass(classToSwizzle)
};
void (*msgSend)(struct objc_super *, SEL) = (__typeof__(msgSend))objc_msgSendSuper;
msgSend(&superInfo, deallocSelector);
} else {
originalDealloc(objSelf, deallocSelector);
}
};
IMP newDeallocIMP = imp_implementationWithBlock(newDealloc);
if (!class_addMethod(classToSwizzle, deallocSelector, newDeallocIMP, "v@:")) {
// The class already contains a method implementation.
Method deallocMethod = class_getInstanceMethod(classToSwizzle, deallocSelector);
// We need to store original implementation before setting new implementation
// in case method is called at the time of setting.
originalDealloc = (void(*)(__unsafe_unretained id, SEL))method_getImplementation(deallocMethod);
// We need to store original implementation again, in case it just changed.
originalDealloc = (void(*)(__unsafe_unretained id, SEL))method_setImplementation(deallocMethod, newDeallocIMP);
}
}
在一个详情里使用了一个带有placeholder的TextView,pop详情时走了dealloc方法,也就是TextView的dealloc里移除了监听placeholder的通知,然而这个时候莫名其妙的crash了,查找之下,发现是一个第三方组组件里hook了delloc方法... 这可咋么办啊 根本不知道从何搞起..
把这个第三方组件删了.显然这是要有大动作...
请问各位大佬们有木有一套行之有效,无痛解决的方法....在线等,急!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…