In my app i want to make PDFDocument from array of images, i use code below for this purpose, but my app crashes because of memory runs out, i used autoreleasepool but that doesn't help. What should i do?
import UIKit
import PDFKit
extension Array where Element: UIImage {
func makePDF()-> PDFDocument? {
let pdfDocument = PDFDocument()
for (index,image) in self.enumerated() {
let pdfPage = PDFPage(image: image)
pdfDocument.insert(pdfPage!, at: index)
}
return pdfDocument
}
}