我正在从iCloud和google drive等中挑选文档,并使用此方法- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
我正在获取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
尝试使用初始化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。
在swift世界中:
URL(fileURLWithPath: "/var/mobile/Containers/Data/Application/34C6FC23-C8BF-407E-AD67-77758BD606E9/Documents/documents/12345678901-1470638583.pdf")
请尝试使用初始化您的文档URL
NSURL*docUrl=[[NSURL分配]initFileURLWithPath:@"file:///var/mobile/Containers/Data/Application/34C6FC23-C8BF-407E-AD67-77758BD606E9/Documents/documents/12345678901-1470638583.pdf"]