【问题标题】:unzip contents in-app purchase ios解压内容应用内购买ios
【发布时间】:2013-10-29 13:59:15
【问题描述】:

在应用内购买的情况下,Apple 托管的内容会以 .zip 格式下载。 我试图解压缩这些内容,但使用 zipArchive 归档打开 .zip 文件。

ZipArchive* za = [[ZipArchive alloc] init];
za.delegate = self;
NSString *path = [download.contentURL path];
if([[NSFileManager defaultManager] fileExistsAtPath:path])
{
    NSLog(@"File Exists: %@", path);
}
else
{
    NSLog(@"file not exists: %@", path);
}


if( [za UnzipOpenFile:path] ) {
    if( [za UnzipFileTo:dir overWrite:YES] != NO )
    {
        NSLog(@"unzip data success");
        //unzip data success
        //do something
    }
    else
    {
        NSLog(@"unzip failed");
    }


    [za UnzipCloseFile];
}
else
{
    NSLog(@"unzip can't open file");
}

输出是

文件存在:....路径.. 解压打不开文件

如果我自己捆绑一个 .zip 文件,它会正常工作

path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"module.zip"];

ZipArchive* za = [[ZipArchive alloc] init];
za.delegate = self;
if([[NSFileManager defaultManager] fileExistsAtPath:path])
{
    NSLog(@"File Exists: %@", path);
}
else
{
    NSLog(@"file not exists: %@", path);
}


if( [za UnzipOpenFile:path] ) {
    if( [za UnzipFileTo:dir overWrite:YES] != NO )
    {
        NSLog(@"unzip data success");
        //unzip data success
        //do something
    }
    else
    {
        NSLog(@"unzip failed");
    }


    [za UnzipCloseFile];
}
else
{
    NSLog(@"unzip can't open file");
}

这里是

File Exists: /var/mobile/Applications/B22970ED-D30A-460A-A0A1-C8458795C370/myApp.app/module.zip

myApp[615:907] 63 entries in the zip file
2013-10-29 18:39:46.012 myApp[615:907] unzip data success

【问题讨论】:

    标签: ios in-app-purchase unzip iap-hosted-content


    【解决方案1】:

    不要尝试解压缩包。这只是一个文件夹。您可以使用此代码查看内容:

    NSArray *tempArrayForContentsOfDirectory =[[NSFileManager defaultManager] contentsOfDirectoryAtPath:[download.contentURL path] error:&error];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-17
      • 2015-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多