How to access files in iCloud Drive from within my iOS app?

后端 未结 5 524
[愿得一人]
[愿得一人] 2020-12-03 02:06

Is there a way to choose file from iCloud Drive similar way to UIImagePickerController()?

5条回答
  •  失恋的感觉
    2020-12-03 02:23

    iCloudUrl.startAccessingSecurityScopedResource() // is returning true for me at this point,

    However the following code gave the error:

    try FileManager.default.createDirectory(atPath: iCloudUrl, withIntermediateDirectories: true, attributes: nil)

    "You can’t save the file “xyz” because the volume is read only."

    This actually works :
    try FileManager.default.createDirectory(at: iCloudUrl, withIntermediateDirectories: true, attributes: nil)

    Which makes sense because the URL probably is carrying around it’s security access, but this little oversight stumped me for half a day…

提交回复
热议问题