Ios 在我的iPad中保存PDF的问题

Ios 在我的iPad中保存PDF的问题,ios,ipad,pdf,Ios,Ipad,Pdf,在我的应用程序中,我从web服务获取PDF作为URL。现在我想把它存储在我的iPad上,并在AdobeReader应用程序中打开。。我使用以下代码保存它,并在webView中打开它 NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[ NSURL URLWithString:socialURLString]]; // S

在我的应用程序中,我从web服务获取PDF作为URL。现在我想把它存储在我的iPad上,并在AdobeReader应用程序中打开。。我使用以下代码保存它,并在webView中打开它

NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[
                                                         NSURL URLWithString:socialURLString]];

// Store the Data locally as PDF File
NSString *resourceDocPath = [[NSString alloc] initWithString:[
                                                              [[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent]
                                                              stringByAppendingPathComponent:@"Documents"
                                                              ]];

NSString *filePath = [resourceDocPath
                      stringByAppendingPathComponent:@"pdfOne.pdf"];
[pdfData writeToFile:filePath atomically:YES];

// Now create Request for the file that was saved in your documents folder
NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

[web setUserInteractionEnabled:YES];
[web setDelegate:self];
[web loadRequest:requestObj];

现在假设它存储在我的iPad中,我打开了AdobeReader应用程序,但它没有显示PDF。我做错了什么?

资源包是一个只读目录及其内容文件。因此,您应该将文件写入临时目录或某个缓存目录

////In temporary directory
NSString *tmpFilePath = [NSString stringWithFormat:@"%@/%@.pdf",NSTemporaryDirectory(),@"pdfOne"];

NSString * filePath = tmpFilePath;


您确定它已正确存储在文档文件夹中吗?否。。我不知道它是否被存储。@rmaddy:我可以从应用程序外部访问pdf吗?我的意思是,我想用Adobe Reader应用程序查看保存的PDF。。有可能吗?我可以从应用程序外部访问pdf吗?我的意思是,我想用Adobe Reader应用程序查看保存的PDF。。是否可能frnd?您可以保存在缓存或临时目录中,并访问相同的。是的,我使用了上面的代码将PDF保存到缓存中。但当我打开Adobe Reader时,保存的PDF不会显示在那里。。我做错了什么?PDF是否下载到缓存目录中?如何检查是否下载到缓存中?
///In caches directory.
    NSString *cacheDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
    NSString *tmpFilePath = [NSString stringWithFormat:@"%@/%@.pdf",cacheDirectoryPath,@"pdfOne"];

    NSString * filePath = tmpFilePath;