2009-10-07 100 views
1

我想在本地通過傳遞文件的URL下載一個EPUB文件中我的應用程序:如何將epub文件本地下載到我們的iPhone?

http://www.jedisaber.com/eBooks/books/sample.epub

點擊這個網址應該下載EPUB。我怎樣才能讓它下載到我的應用程序?

我試過使用NSData,但它沒有工作。我也嘗試將文件複製到我的文檔目錄,但它也沒有工作。任何人都可以告訴我如何在Objective-C中做到這一點?

任何幫助代碼將不勝感激!

感謝您的任何幫助。

+0

嗨,你覺得對於上述問題。如果是比的解決方案,請在以下鏈接給我寫信。感謝提前。 http://stackoverflow.com/questions/16416640/how-to-download-epub-format-file-from-url-to-document-directory-in-iphone – 2013-05-07 12:35:12

回答

2

EPUB是一種ZIP格式,您可以使用任何二進制流式下載方法,並將文件首先保存爲iPhone上的二進制文件。

0

AS ARCON提到EPUB是一個ZIP格式,您必須將文件解壓縮到 解壓縮文件&保存文檔目錄烏爾機: ZipArchive * ZA = [[ZipArchive的alloc]初始化] 如果([ZA UnzipOpenFile:[一個NSBundle mainBundle] pathForResource:@ 「幫助」 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]; 
相關問題