好的,我有iPad的应用程序阅读杂志。所有以前的问题都可以。我设法做出新的问题(在其他人离开公司之前完成)并在模拟器和设备上运行它没有问题。
现在我在数据库中为杂志的新版本添加行并通过ZIP工具压缩所有图片和多媒体并将其划分为MacHacha(因为从MacHacha上传需求部分的Java类逐个上传)并将其上传到服务器上。在App商店我下载了杂志,可以看到新的问题。在服务器上,新行具有良好的所有参数,并且大小足以在磁盘上调整大小。
当新问题芬兰语下载时,它会显示错误。我从模拟器和OUTPUT尝试了相同的程序,它崩溃的那一刻显示我的解压缩错误(0)。
我认为问题在于将部件与MacHacha放在一起。任何人都可以帮助或给我解决这个问题的捕获。
如果它有帮助我可以上传新问题并提供链接(它是免费的)我会对你们这些人和女孩有所帮助:))
http://www.mazzantieditori.it/applicazioni/219-nycit-italian-american-magazine.html
申请链接。在图书馆中几乎没有问题,最后一个是新的(Giugno 2011)。
我将提供该方法的代码,该代码为我提供错误的字符串:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// controllo se ilreceiptècorttte faccio partire il download
if(min == 0&& [receivedData length]
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];
}
提前致谢...