7

I am using pdfKit on CollectionViewController and each cell has a different PDF for it, and PDF will be downloaded from the document directory.

When I use the following code under iOS 11 then it works fine. However, when I use it on iOS 12, I get a memory leak and a subsequent crash.

This is the error I get:

Thread 4: EXC_BAD_ACCESS (code=1, address=0x107b5401c)

This is my code:

func loadData(_ finame: String) {
    let dbPath = finame
    let url = URL(fileURLWithPath: dbPath)
    if let pdfDocument = PDFDocument(url: url) {
        self.pdfView.document = pdfDocument
        self.pdfView.autoScales = true
        self.pdfView.maxScaleFactor = 4.0
        self.pdfView.minScaleFactor = pdfScaleFactor
        if #available(iOS 12.0, *) {
            self.pdfView.pageShadowsEnabled = false
        }
    }
}

How can I fix this problem?

grooveplex
  • 2,492
  • 4
  • 28
  • 30

0 Answers0