简体   繁体   English

如何在iPhone应用程序中从SkyDrive保存和检索下载的pdf文件

[英]How to save and retrieve downloaded pdf files from skydrive in iphone application

I am integrating sky drive in my iPhone application,I am trying to download pdf file from sky drive and I want to show that downloaded pdf file through application.Anyone knows about sky drive API's for iOS. 我正在将Sky Drive集成到我的iPhone应用程序中,我正试图从sky drive下载pdf文件,我想通过应用程序显示下载的pdf文件。任何人都知道iOS的sky drive API。 How to save and show downloaded pdf file from sky drive.Please help me. 如何保存和显示从天空驱动器下载的pdf文件。请帮助我。

To get a file from the web and store it locally, you can use NSData: 要从网络获取文件并将其存储在本地,可以使用NSData:

NSString *stringURL = @"http://www.somewhere.com/thefile.pdf";
NSURL  *url = [NSURL URLWithString:stringURL];
NSData *urlData = [NSData dataWithContentsOfURL:url];
if ( urlData )
{
  NSArray       *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString  *documentsDirectory = [paths objectAtIndex:0];  

  NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"filename.pdf"];
  [urlData writeToFile:filePath atomically:YES];
}

You can use Live SDK for iOS . 您可以使用Live SDK for iOS For download files you can use downloadFromPath: method of LiveConnectClient class instance. 对于下载文件,可以使用LiveConnectClient类实例的downloadFromPath:方法。 Live SDK developer guide will help you. Live SDK开发人员指南将为您提供帮助。 For choose way display pdf you can use this answer. 对于选择方式显示pdf,您可以使用答案。

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

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