Ios 使用macHacha组装零件时出现解压缩错误
好的,我有一个可以阅读杂志的iPad应用程序。以前的所有问题都很好。我设法制作了一个新版本(在另一个离开公司的家伙完成之前),并在模拟器和设备上运行它,没有任何问题 现在,我在数据库中为新一期杂志添加行,并使用ZIP工具压缩所有图片和多媒体,并将它们除以MacHacha(因为上传的Java类需要MacHacha的部分逐个上传),然后上传到服务器上。在应用商店里我下载了杂志,可以看到新的一期。在服务器上,新行是良好的,具有所有良好的参数,并且大小足以满足磁盘上的大小 当新发行的芬兰语下载它显示我的错误。我在模拟器上尝试了相同的过程,在它崩溃的那一刻,输出中显示了解压缩错误(0) 我想问题在于把零件和马查卡组装在一起。有人能帮我解决这个问题吗 如果有帮助的话,我可以上传新版本并提供链接(这是免费的),我会对你们有帮助:) 应用程序的链接。在图书馆里,几乎没有问题,最后一个是新的(Giugno 2011) 我将为该方法提供代码,该方法为我提供错误字符串:Ios 使用macHacha组装零件时出现解压缩错误,ios,ipad,compression,Ios,Ipad,Compression,好的,我有一个可以阅读杂志的iPad应用程序。以前的所有问题都很好。我设法制作了一个新版本(在另一个离开公司的家伙完成之前),并在模拟器和设备上运行它,没有任何问题 现在,我在数据库中为新一期杂志添加行,并使用ZIP工具压缩所有图片和多媒体,并将它们除以MacHacha(因为上传的Java类需要MacHacha的部分逐个上传),然后上传到服务器上。在应用商店里我下载了杂志,可以看到新的一期。在服务器上,新行是良好的,具有所有良好的参数,并且大小足以满足磁盘上的大小 当新发行的芬兰语下载它显示我的
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{//CONTROLO se il RECEINTècorretto e faccio partire il下载 如果(最小==0&&[receivedData长度]
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];
NSString*文件=[[self-documentsDir:1]stringByAppendingPathComponent:@“archivio.zip”];
如果(max=kMinPartSize){
NSLog(@“prod%@”,self.prodName);
如果(self.prodName==nil | |[self.prodName isEqualToString:@”“])self.prodName=prodId;
n错误*错误;
BOOL ok=[TWZipArchive unzipFileAtPath:file toDestination:[self documents dir:1]覆盖:是密码:无错误:&error];
//unzipFileAtPath:filetodestination:[self-documentsDir]];
NSString*msg;
如果(确定){
NSLog(@“解压缩成功”);
self.progressBar.progress=1.0f;
NSFileManager*fm=[NSFileManager defaultManager];
[fm removeItemAtPath:文件错误:&错误];
msg=@“下载完成:图书馆新增新版本”;
NSMutableArray*数组;
NSMutableDictionary*dict=[NSMutableDictionary];
NSString*path=[[self-documentsDir:0]stringByAppendingPathComponent:@“download.plist”];
如果(![[NSFileManager defaultManager]fileExistsAtPath:path]){
[dict setObject:prodId forKey:@“id”];
[dict setObject:prodName forKey:@“titolo”];
array=[NSArray arrayWithObject:dict];
[数组写入文件:原子路径:是];
}
数组=[NSMUTABLEARRY ARRAYWITHCONTENTSOFILE:path];
BOOL exist=NO;
对于(inti=0;i我不知道x代码,但这是一个有用的库
Traduci i commenti dall'italiano che sennòsono inutili![翻译意大利语的评论,否则毫无意义]