我在应用程序商店中有一个应用程序,有崩溃的报告,从日志点到下面的功能之一。由于我不具备重现它的确切方案,因此处理它的最佳方法是什么。在测试时,即使我将nil传递给messageJSON字符串,它仍然不会崩溃。知道什么可能导致崩溃以及如何处理它?
- (void)_dispatchMessage:(WVJBMessage *)message {
NSString * messageJSON = [self _serializeMessage:message];
//崩溃日志指向下面的这一行
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@" \\" withString:@" \\\\"];
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@" \"" withString:@" \\\""];
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@" \'" withString:@" \\\'"];
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@" \ n" withString:@" \\ N'#34;];
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@" \ r" withString:@" \\ R"];
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@" \ f" withString:@" \\ F"];
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@" \ u2028" withString:@" \\ u2028"];
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@" \ u2029" withString:@" \\ u2029"];
NSString * javascriptCommand = [NSString stringWithFormat:@" WebViewJavascriptBridge._handleMessageFromObjC('%@');",messageJSON];
if([[NSThread currentThread] isMainThread]){
[_webView stringByEvaluatingJavaScriptFromString:javascriptCommand];
} else {
__strong WVJB_WEBVIEW_TYPE * strongWebView = _webView;
dispatch_sync(dispatch_get_main_queue(),^ {
[strongWebView stringByEvaluatingJavaScriptFromString:javascriptCommand];
});
}
}