-->

如何在本地下载的ePub文件,我们的iPhone?(How to download an epub

2019-07-21 08:13发布

我想在本地通过传递文件的URL下载到我的应用程序ePub文件:

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

点击这个网址应该下载EPUB。 我怎样才能得到它下载到我的应用程序?

我尝试使用NSData的,但没有奏效。 我也试着将文件复制到我的文档目录,但它也没有工作。 谁能告诉我,我怎么能做到这一点在Objective-C?

任何帮助的代码,将不胜感激!

谢谢你的帮助。

Answer 1:

EPUB是一个ZIP格式,你可以使用任何二进制流下载方法和第一个文件保存为在iPhone上的二进制文件。



Answer 2:

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


文章来源: How to download an epub file locally to our iPhone?
标签: iphone epub