简体   繁体   中英

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

I am downloading multiple pdf files from server. once download is completed I need to save the pdf files in local and fetch from pdf files and display the pdf files in UIDocument interaction controller. I am writing like this. but only one file shown.remaining files are not displayed.

- (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"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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