NSArrayURL , userDefault filePath and URL

前端 未结 1 934
攒了一身酷
攒了一身酷 2021-01-28 05:01

I have one pdf source code and I want to add the Url in Array and use UserDefault

let defaults = UserDefaults.standard

struct Constants {

    static let myKeyU         


        
相关标签:
1条回答
  • 2021-01-28 06:00

    The error is clear:

    PDFDocument(url: expects URL, you pass String which is a classic type mismatch.

    You have to create URL instances from the strings

    documents = arrayUrl.flatMap { PDFDocument(url: URL(fileURLWithPath: $0) ) }
    

    However you are discouraged from saving the full path because the path to the Documents folder changes. Save only the file name or relative path and get the actual path to the Documents folder on each application launch.

    0 讨论(0)
提交回复
热议问题