Closed Jeykit closed 5 years ago
之前的版本在真机测试下这里不崩溃,模拟器崩溃,但是最新xcode打的包必崩。
我调了一下,是由于- (void)nativeWeb:(NSDictionary *)data,而web端并无传参导致的。目前是这么调了下。
if (arg == nil) { arg = [NSNull null]; } SuppressPerformSelectorLeakWarning( ret=[JavascriptInterfaceObject performSelector:sel withObject:arg]; );
具体我也没通篇阅读源代码所以我也不知道其实会造成啥后果,但是至少不崩溃了。
@Platycodon API签名不对就会导致Crash:
返回值类型不能是void
我也遇到这个crash了。我的返回值是bool,我试了下其它类型UIimage居然没有crash
找到原因了: 约定的方法需要有返回值!
ret=[JavascriptInterfaceObject performSelector:sel withObject:arg];.//这个方法会导致野指针崩溃问题 建议改成 void(action)(id,SEL,id) = (void()(id,SEL,id))objc_msgSend; action(JavascriptInterfaceObject,sel,arg);