2013-03-05 86 views
1

由于密码学出口法规,有可能使用这个库吗?或者我可以使用哪一种压缩/解压缩文件?它允许在App Store中使用ssziparchive库吗?

+1

你问关于使用密码保护的zip文件,或者你真的只需要一个普通的旧zip /解压缩库? – rmaddy 2013-03-06 00:00:11

+0

对不起,如果我不清楚,我只想压缩/解压缩,不需要/想要加密 – aprunedamtz 2013-03-06 22:18:04

+0

尝试Objective-Zip,ZipKit或普通的旧的minizip。 – rmaddy 2013-03-06 22:45:19

回答

1

我不知道SSZipArchive是否允许在分布式应用程序中使用,但我使用的库是Objective-Zip

它可以很容易地集成到任何项目。为压缩和解

示例代码:

// create a zip file for writing 
ZipFile *zipFile= [[ZipFile alloc] initWithFileName:pathOfTheFileToBeZipped mode:ZipFileModeCreate]; 

// Add a file, write to its stream and close it 
ZipWriteStream *stream1= [zipFile writeFileInZipWithName:@"abc.txt" fileDate:[NSDate dateWithTimeIntervalSinceNow:-86400.0] compressionLevel:ZipCompressionLevelBest]; 
NSString *text= @"abc"; 
[stream1 writeData:[text dataUsingEncoding:NSUTF8StringEncoding]]; 
[stream1 finishedWriting]; 

// Add another file, write to its stream and close it 
ZipWriteStream *stream2= [zipFile writeFileInZipWithName:@"x/y/z/xyz.txt" compressionLevel:ZipCompressionLevelNone]; 
NSString *text2= @"XYZ"; 
[stream2 writeData:[text2 dataUsingEncoding:NSUTF8StringEncoding]]; 
[stream2 finishedWriting]; 

// Close the zip file 
[zipFile close]; 

示例代码解压:

// open the zip file for reading 
ZipFile *unzipFile = [[ZipFile alloc] initWithFileName:pathOfTheFileToBeUnzipped mode:ZipFileModeUnzip]; 

// retrieve the info of the files inside 
NSArray *infos= [unzipFile listFileInZipInfos]; 

// iterate over files 
for (FileInZipInfo *info in infos) {   
    // locate the file in the zip 
    [unzipFile locateFileInZip:info.name]; 

    // expand the file in memory 
    ZipReadStream *read= [unzipFile readCurrentFileInZip]; 
    NSData *data = [read readDataOfLength:info.length]; 
    [read finishedReading]; 

    // construct the folder/file path structure 
    NSString *unzipPathFilename = [unzipPath stringByAppendingPathComponent:info.name]; 
    NSString *unzipPathFoldername = [[unzipPathFilename stringByDeletingLastPathComponent] copy]; 
    NSError *errorw; 

    // write the unzipped files, with some consistency checks 
    NSRange range = [unzipPathFoldername rangeOfString:@"__MACOSX"]; 

    if (range.location == NSNotFound) { 
     if ([fileManager createDirectoryAtPath:unzipPathFoldername withIntermediateDirectories:YES attributes:nil error:&errorw]) { 
      if (![[unzipPathFilename pathExtension] isEqualToString:@""] && ![[[unzipPathFilename lastPathComponent] substringToIndex:1] isEqualToString:@"." ]) { 
       [data writeToFile:unzipPathFilename atomically:NO]; 
      } 
     } 
     else { 
      NSLog(@"Directory Fail: %@", errorw); 
     } 
    } 
} 

// close the zip file 
[unzipFile close]; 
+0

第二部分是他的问题是询问他应该使用哪个库来进行压缩/解压缩。他没有严格规定他需要加密,而是询问是否允许使用使用加密的SSZipArchive,这是我不知道的。 – tolgamorf 2013-03-05 23:58:56

+0

我不想/需要加密,这个库Objective-Zip使用加密?感谢您的回答 – aprunedamtz 2013-03-06 22:23:05

+0

不,它不使用加密。但是,如果需要,您可以使用密码保护您的zip文件。 – tolgamorf 2013-03-07 01:21:39

0

其实你都不允许有加密的iOS应用。 您只需向NSA提交您的应用程序以及应用程序的加密类型。 回复您的注册号码通常需要30分钟。 它是自动或半自动的。 他们只是收集有关开发人员的信息。

作为iOS开发者注册更简单。

我的看法: -

如果不使用ZIP库加密,那么你应该提交的任何应用程序。 链接器将优化后删除该代码。 该代码未被使用。但是,如果你使用加密,即使是iOS来的,那么你应该申请。 例如如果UIWebView打开https:// URL(例如Facebook),但如果使用UIWebView打开不安全的页面,则不应用。

+0

很高兴知道,谢谢 – aprunedamtz 2013-03-08 17:23:23

相关问题