2012-01-30 113 views
1

我想下载的EPUB书,并将其保存到我的目录,然后在网页视图打开的书。我知道如何在webview中打开一本书,我不知道如何下载epub书并将其保存到我的文档中。我试图解开链接,但我给我的任何链接只能看到help.epub书。我无法在我的文档中看到我需要的epub书。 用于解链的代码是:下载EPUB图书编程和文档目录保存在Xcode

(void)unzipAndSaveFile{ 

    ZipArchive* za = [[ZipArchive alloc] init]; 
    NSLog(@"url%@",receivedUrl); 
    NSLog(@"recieved%@",receivedTitle); 
    if([za UnzipOpenFile:[[NSBundle mainBundle] pathForResource:receivedTitle ofType:@"epub"]]){ 

    NSString *strPath=[NSString stringWithFormat:@"%@/UnzippedEpub",[self applicationDocumentsDirectory]]; 
    //Delete all the previous files 
      NSFileManager *filemanager=[[NSFileManager alloc] init]; 
      if ([filemanager fileExistsAtPath:strPath]) { 
       NSError *error; 
       [filemanager removeItemAtPath:strPath error:&error]; 
      } 
      [filemanager release]; 
      filemanager=nil; 

    //start unzip 
    [za UnzipFileTo:strPath overWrite:YES]; 
    NSLog(@"path%@",strPath); 
     }     
    [za release]; 
} 

我已经使用JSON解析的数据。

+0

pathForResource:receivedTitle ---在这里 “receiveTitle” 我是路过的epub的链接。请大家帮我理清这个问题... – iOSDev 2012-01-30 05:32:11

回答

0

要解压,首先需要在您的本地存储的iOS的EPUB的文件等,据我所知,你不能直接通过URL做到这一点。

所以,先下载它,将它保存(例如,在文档目录),然后调用上面pathForResource是路径的文件目录中的文件.epub代码。

希望这可以帮助你!

+0

感谢ü的答复,我可以直接存储在EPUB,但每当我要检查我只能看到help.epub和无法找到其他EPUB – iOSDev 2012-01-30 06:16:10

相关问题