0

我正在从 iCloud 和谷歌驱动器等中挑选文件并使用这种方法- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url

我正在获取网址file:///private/var/mobile/Containers/Data/Application/34C6FC23-C8BF-407E-AD67-77758BD606E9/tmp/com.company.theApp-Inbox/chart%20(1).pdf

但是当我这样做时[[NSFileManager defaultManager]copyItemAtURL:url toURL:docUrl error:&error];

我收到此错误Error Domain=NSCocoaErrorDomain Code=262 "The file couldn’t be opened because the specified URL type isn’t supported." UserInfo={NSURL=/var/mobile/Containers/Data/Application/34C6FC23-C8BF-407E-AD67-77758BD606E9/Documents/documents/12345678901-1470638583.pdf}

这是我的docUrl = /var/mobile/Containers/Data/Application/34C6FC23-C8BF-407E-AD67-77758BD606E9/Documents/documents/12345678901-1470638583.pdf

4

3 回答 3

2

尝试初始化你docUrl的:

NSURL *docUrl = [[NSURL alloc] initFileURLWithPath:@"/var/mobile/Containers/Data/Application/34C6FC23-C8BF-407E-AD67-77758BD606E9/Documents/documents/12345678901-1470638583.pdf"];

我猜这copyItemAtURL:toURL:error:不会将您的 URL 识别为文件 URL。

于 2016-08-08T07:46:17.503 回答
0

在迅捷的世界里:

URL(fileURLWithPath: "/var/mobile/Containers/Data/Application/34C6FC23-C8BF-407E-AD67-77758BD606E9/Documents/documents/12345678901-1470638583.pdf")
于 2018-05-15T02:16:23.697 回答
-3

请尝试使用以下方法初始化您的 docUrl:

NSURL *docUrl = [[NSURL alloc] initFileURLWithPath:@"file:///var/mobile/Containers/Data/Application/34C6FC23-C8BF-407E-AD67-77758BD606E9/Documents/documents/12345678901-1470638583.pdf"]

于 2017-02-10T08:52:59.427 回答