gpt4 book ai didi

ios - 用macHacha拼零件时解压出错

转载 作者:行者123 更新时间:2023-11-28 23:15:39 25 4
gpt4 key购买 nike

好的,我有适用于 iPad 的阅读杂志的应用程序。以前的所有问题都可以正常工作。我设法提出新问题(在离开公司的其他人完成之前)并在模拟器和设备上毫无问题地运行它。

现在我在数据库中添加新一期杂志的行,并通过ZIP工具压缩所有图片和多媒体,然后通过MacHacha将它们分开(因为上传的Java类需要MacHacha的部分逐个上传)并上传到服务器上。在 App store 我下载了杂志,可以看到新一期。服务器上的新行很好,具有所有良好的参数,并且大小足以满足磁盘上的大小。

当新一期芬兰语下载时,它显示错误。我在模拟器和输出中尝试了相同的程序,当它崩溃时显示解压缩错误(0)。

我认为问题在于将零件与 MacHacha 放在一起。任何人都可以帮助或给我解决这个问题的方法。

如果有帮助,我可以上传新一期并提供链接(免费)我对你们有帮助 :)

http://www.mazzantieditori.it/applicazioni/219-nycit-italian-american-magazine.html

申请链接。在图书馆中,有几期,最后一期是新的(Giugno 2011)。

我将提供该方法的代码,该方法会给出错误的字符串:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection

{
//控制收据 è corretto e faccio partire il download if(min == 0 && [接收数据长度]

NSString *file = [[self documentsDir:1] stringByAppendingPathComponent:@"archivio.zip"];

if (max <= num && !cancelDownload) {
self.progressBar.progress = (1.0f/num)*min;
min = max+1;
max += 5;

// creo directory per l'elemento scaricato
BOOL isDir = NO;

if(![[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDir]) {
NSError *error;
//creo directory
[[NSFileManager defaultManager] createDirectoryAtPath:[self documentsDir:1] withIntermediateDirectories:YES attributes:nil error:&error];
//creo file vuoto
[[NSFileManager defaultManager] createFileAtPath:file contents:nil attributes:nil];
}

NSFileHandle *handler = [NSFileHandle fileHandleForWritingAtPath:file];

if(handler) {
[handler seekToEndOfFile];
[handler writeData:receivedData];
}
NSLog(@"Received %d bytes of data; min: %i max: %i",[receivedData length],min,max);
[receivedData setLength:0];

// questa è la seconda invocazione
[self downloadArchivePart:@"verified"];
[connection release];
return;
}

NSFileManager *man = [[NSFileManager alloc] init];
NSDictionary *attrs = [man attributesOfItemAtPath:file error: NULL];
//UInt32 result =
NSNumber *size = [attrs objectForKey:NSFileSize];
//int length = [receivedData length];
NSLog(@"Succeeded! Received %i bytes of data",[size intValue]);
[man release];

//1.038.090 è il numero di byte della parte più piccola dell'archivio
if([size intValue] >= kMinPartSize) {

NSLog(@"prod %@",self.prodName);
if(self.prodName == nil || [self.prodName isEqualToString:@""]) self.prodName = prodId;

NSError *error;
BOOL ok = [TWZipArchive unzipFileAtPath:file toDestination:[self documentsDir:1] overwrite:YES password:nil error:&error];
//unzipFileAtPath:file toDestination:[self documentsDir]];

NSString *msg;
if(ok) {
NSLog(@"decompression successfull");
self.progressBar.progress = 1.0f;
NSFileManager *fm = [NSFileManager defaultManager];
[fm removeItemAtPath:file error:&error];
msg = @"Download completed: new issue added in libray";

NSMutableArray *array;
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSString *path = [[self documentsDir:0] stringByAppendingPathComponent:@"downloaded.plist"];
if(![[NSFileManager defaultManager] fileExistsAtPath:path]) {
[dict setObject:prodId forKey:@"id"];
[dict setObject:prodName forKey:@"titolo"];
array = [NSArray arrayWithObject:dict];
[array writeToFile:path atomically:YES];
}
array = [NSMutableArray arrayWithContentsOfFile:path];
BOOL exist = NO;
for (int i=0; i<[array count]; i++) {
if ([[[array objectAtIndex:i] objectForKey:@"id"] isEqualToString:prodId]) {
exist = YES;
//prodId = [NSString stringWithFormat:@"%@%i",prodId,i];
}
}

if(exist == NO) {
[dict setObject:prodId forKey:@"id"];
[dict setObject:prodName forKey:@"titolo"];
[array insertObject:dict atIndex:0]; //sempre in testa l'ultimo elemento scaricato
[array writeToFile:path atomically:YES];
}

}
else {
NSLog(@"decompression error");
msg = @"An error has occurred";
}

//[myAlert release];
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"NYC.IT"
message:@"Download completed: new issue added in libray"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];

//[alert release];
}else {

if(cancelDownload == YES) {

UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"NYC.IT"
message:@"Download stopped for user action"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];

}else {

NSString *errFile = [[self documentsDir:1] stringByAppendingPathComponent:@"errFile.html"];
[receivedData writeToFile:errFile atomically:YES];
NSLog(@"err : %@",errFile);
NSLog(@"scrittura error file eseguita");

NSLog(@"receipt non valido");
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"NYC.IT"
message:@"Downloading error: please retry later!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
}


}
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
progressBar.hidden = YES;

// release the connection, and the data object
[connection release];
//[receivedData release];

提前致谢...

最佳答案

我不知道 x-code 但这是一个有用的库 http://www.winimage.com/zLibDll/minizip.html

关于ios - 用macHacha拼零件时解压出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6583331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com