From 44f52847e41b86700337b7fb8bcac280e5c30268 Mon Sep 17 00:00:00 2001 From: Andy Kayley Date: Thu, 14 Apr 2016 10:51:03 +0100 Subject: [PATCH] UIKit crash fixes. We had numerous UIKit crashes using this library. We found that adding the dealloc method and calling terminateWebTask fixed most of these crashes, then there was another crash less frequent when the view in terminateWebTask was already nil when removeFromSuperview is called. --- NDHTMLtoPDF.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/NDHTMLtoPDF.m b/NDHTMLtoPDF.m index 7bdc154..ff3de35 100644 --- a/NDHTMLtoPDF.m +++ b/NDHTMLtoPDF.m @@ -212,11 +212,18 @@ - (void)terminateWebTask self.webview.delegate = nil; [self.webview removeFromSuperview]; - [self.view removeFromSuperview]; + if (self.view) { + [self.view removeFromSuperview]; + } self.webview = nil; } +- (void) dealloc +{ + [self terminateWebTask]; +} + @end @implementation UIPrintPageRenderer (PDF)