Stop a queue

Above ViewDidLoad:

private var workItem: DispatchWorkItem?

In ViewDidLoad or where the queue shows:
workItem = DispatchWorkItem {
           
    //actions in the queue
            
        }

        DispatchQueue.main.asyncAfter(deadline: .now(), execute: workItem!)

In ViewDidDisappear
//if loading web view
self.nameOfWebView.stopLoading()
        workItem?.cancel()

Comments

Popular posts from this blog

Setting up a playground

Go to another page