我正在嘗試實現移動和導出模式的功能。我所做的只是讓用戶導航到他們想要移動/導出文件的目錄,然後在所選目錄中調用dismissGrantingAccessToURL,並附加原始文件的文件名。下面是它的外觀在代碼:移動或導出模式中的DocumentPickerViewController被一個不存在的URL取消(使文檔提供程序應用程序擴展)
let moveDestinationPath = self.currentDirectory.path.stringByAppendingPathComponent(AppHelper.Stored.originalURL!.lastPathComponent)
delegate.finishWithURL(NSURL.fileURLWithPath(moveDestinationPath))
我認爲這應該足夠了,因爲該文件說以下內容:
Export Document Picker mode. Provide a URL for the selected destination. This URL needs to be accessible only by the Document Picker View Controller extension. The system saves a copy of the document at this URL and returns the URL to the host app to indicate success. The host app cannot access the document at this URL.
Move Document Picker mode. Provide a URL for the selected destination. The URL needs to be contained inside the hierarchy referred to by your documentStorageURL property. The system moves the document to this URL and returns the URL to the host app. The host app can then access the document at the new URL.
然而,當我運行此代碼,我得到以下錯誤:
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '<TestDocumentProvider.DocumentPickerViewController: 0x7c470770> was
dismissed with a nonexistent URL (file:///Users/test/Library/Developer/CoreSimulator
/Devices/6867B1A7-8694-4D6D-8480-69FE89F39C27/data/Containers/Shared/AppGroup/74A2FBED-
70C5-4F24-8345-AD35FEB86D01/FileProviderStorage/Directory1/apple1.png)
in Move or Export mode'
鑑於此錯誤,看來他們希望我用手移動或文件在原來的網址在自己複製。但是這與文檔中所說的內容相矛盾(關於系統執行的部分)。
那麼,任何人都知道蘋果打算在這種情況下做什麼?現在我可能只是去做移動/複製我自己的路線...