0
私のzipファイルのダウンロードを実行する次のzipfileクラスがあります。私はzipファイルに関連付けられたファイル名を持っています。私はviewcontrollerクラスに渡すファイル名を知る必要があります。別のクラスの値にアクセスしようとすると、常にnullが返されます。私は実際にどのように私はZipFileからのresponseStringを使用して、それをViewControllerで使うことができるか知りたいです。別のクラスのNSURLResponseにアクセスする方法
/ZipFile.m/
-(NSString *) downloadZipFile{
fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
directoryPath = [paths objectAtIndex:0];
filePath = [NSString stringWithFormat:@"%@/ZipFiles.zip", directoryPath];
NSURL *url=[NSURL URLWithString:@"http://www.abc.com/id=123"];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSError *error1;
urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error1];
[fileManager createFileAtPath:filePath contents:urlData attributes:nil];
[SSZipArchive unzipFileAtPath:filePath toDestination:directoryPath];
NSLog(@"Finished unzipping database");
Tab_Table_WinAppDelegate *appDelegate = [[[Tab_Table_WinAppDelegate alloc] init] autorelease];
[appDelegate loadingViewControllerDidFinish];
NSString *total = [self total]; // returns value here
return total;
}
- (NSString *)total {
NSString *responseString = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding];
NSString *fileName = [response suggestedFilename];
NSLog(@"Value : %@", fileName);
return fileName;
}
/* ViewController.m *新しいZIPファイル、おそらくにISN作成/
- (CGSize)imageSizeAtIndex:(NSUInteger)index {
CGSize size = CGSizeZero;
if (index < [self imageCount]) {
ZipFile *map = [[ZipFile alloc]init];
size.width = [[map total] floatValue]; // returns null here
[map release];
}
return size;
}
ありがとうございます。しかし、私はあなたが何を意味するのか明確に理解していませんでした私のコントローラにZipFileオブジェクトを渡すにはどうすればいいですか? – lifemoveson