UIWebView in multithread ViewController

前端 未结 8 841
日久生厌
日久生厌 2020-12-24 09:38

I have a UIWebView in a viewcontroller, which has two methods as below. The question is if I pop out(tap back on navigation bar) this controller before the second thread is

8条回答
  •  [愿得一人]
    2020-12-24 10:06

    I tried both solutions posted above, [operationQueue cancelAllOperations], and [[self retain] autorelease]. However, with quick clicking, there are still cases where the retain count falls to 0 and the class gets deallocated on the secondary thread. In order to avoid a crash, I put the following in my dealloc for now:

        if ([NSThread isMainThread]) {
            [super dealloc];
        }
    

    which is an obvious leak, but seems to be the lesser of 2 evils.

    Any additional insight from anyone encountering this problem is welcome.

提交回复
热议问题