I made an pdf creator app. After creating pdf file I want to display the created files on a tableview
. I created Tableview Controller and DocumentDirectoryTableTableViewController
. I don't know how to do it after all of that.
I found this and this questions but I couldn't implement it into my code.
Also better to add my code for saving file:
// 5. Save PDF file
let path = "/MyApp/PdfFiles/MyPDF.pdf"
pdfData.write(toFile: path, atomically: true)
print("open \(path)") // command to open the generated file
UPDATE: I can also get the App Directory and use it by this function:
func getDocumentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let documentsDirectory = paths[0]
return documentsDirectory
}
and
let path = "\(getDocumentsDirectory())MyApp.pdf"