2016-08-08 52 views
0

我從採摘的iCloud和谷歌文檔等驅動,並使用這種方法- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url獲取錯誤 - (BOOL)copyItemAtURL:(NSURL *)srcURL的toURL:(NSURL *)dstURL錯誤:(NSError **)錯誤

我收到網址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

回答

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。

+0

這是我在做什麼NSURL * docUrl = [NSURL URLWithString:[documentFolderDataPath stringByAppendingPathComponent:FN]]; –

+0

如果你改變它:'NSURL * docUrl = [NSURL fileURLWithPath:[documentFolderDataPath stringByAppendingPathComponent:fn]];'? – Roy

+0

非常感謝:) ..... –

-3

請嘗試用初始化您docUrl:

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