繁体   English   中英

如何在Objective-C的NSDocument目录中保存和获取多个pdf文件?

[英]How to save and fetch multiple pdf files in NSDocument Directory in Objective-C?

我正在从服务器下载多个 pdf 文件。 下载完成后,我需要将 pdf 文件保存在本地并从 pdf 文件中获取并在 UIDocument 交互控制器中显示 pdf 文件。 我是这样写的。 但只显示一个文件。剩余的文件不会显示。

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [self.data appendData:data];

    NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];        // get 
    /tmp folder path

    NSURL *fileURL = [[tmpDirURL URLByAppendingPathComponent:@"temp_pdf"] URLByAppendingPathExtension:@"pdf"];

    [self.data writeToURL:fileURL atomically:YES];

    self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];

    self.documentInteractionController.delegate = self;

    [self.documentInteractionController presentPreviewAnimated:YES];
}

NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *filePath = [documents stringByAppendingPathComponent:@"file.plist"];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM