If I want create pdf to var dokumnetpdf from picker, var dokumnetpdf is empty. How I do that?
myCode:
var dokumnetpdf = PDFDocument()
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let myURL = urls.first else {
return
} //print("import result : (myURL)") let url: URL = myURL //print("PDF link:(myURL)") pdfname = url.lastPathComponent // print("PDF name: (pdfname)") // textfield.text = pdfname dokumnetpdf = PDFDocument(url: urls.first!) }
Error LoG:
import result : file:///private/var/mobile/Library/Mobile%20Documents/comappleCloudDocs/Desktop/rezervacefo.pdf
PDF link:file:///private/var/mobile/Library/Mobile%20Documents/comappleCloudDocs/Desktop/rezervacefo.pdf
PDF name: rezervacefo.pdf
doc:nil
AMC/DocumentUploadViewController.swift:68: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
2022-01-07 11:11:49.159474+0100 AMC[71388:8043348] AMC/DocumentUploadViewController.swift:68: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value