Posts

Post not yet marked as solved
3 Replies
262 Views
Hello everybody, I am struggling with accessing files from the Location OneDrive through UIDocumentViewController. The error says: Error Domain=NSCocoaErrorDomain Code=260 "Die Datei „Testfile.txt“ konnte nicht geöffnet werden, da sie nicht existiert." UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/11E04153-649E-416F-9860-2EA9C0913A18/File Provider Storage/item|1|18a17c69%2D5d6d%2D4b16%2Db388%2D4a9834e9440b/Testfile.txt, NSUnderlyingError=0x281202310 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} The Controller is initialised the following way: let ctrl = UIDocumentPickerViewController(forOpeningContentTypes: [.image, .audio, .video, .item, .content]) And in the delegate method I do the following: func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { guard let documentUrl = urls.first else { return } guard documentUrl.startAccessingSecurityScopedResource() else { parent.errorText = "Developer Error: Can't access security scoped resource." return } defer { documentUrl.stopAccessingSecurityScopedResource() } do { let data = try Data(contentsOf: documentUrl) } catch { parent.errorText = error.localizedDescription } } Any help is appreciated! Thanks
Posted Last updated
.