I'm having a little problem using NSURLDownload
. Basically I'm downloading two different files using the following code twice with the variable names changed.
NSURLRequest *requestUserfile = [NSURLRequest requestWithURL:[NSURL URLWithString:requestAgent_url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLDownload *downloadUserFile = [[NSURLDownload alloc] initWithRequest:requestUserfile delegate:self];
NSString *uf_tpath = [ [ [NSBundle mainBundle] bundlePath ] stringByAppendingPathComponent:@"userfile"];
if (downloadUserFile) {
[downloadUserFile setDestination:uf_tpath allowOverwrite:YES];
} else {
NSLog("ERROR: Problem while downloading user file [1].");
exit(0);
}
But I've a problem, according to Apple class reference this code is asynchronous and it calls - (void)downloadDidFinish:(NSURLDownload *)download
when the download is finished.
My program needs the two files downloaded to a folder before start doing any processing, so how can I know when the two of them are downloaded? that will be called when the first one is finished :S
My first idea was to place the second file download int the downloadDidFinish
of the first one... but then I will run into an infinite loop and I'll have two methods with the same name :S
PS: I'm new to Obj-C and Xcode, I used to do this using signals and slots on QT but there I can just define two slots different slots and connect them on right time.
Thanks.