0
votes

I'm trying to download a file in my cocoa app as follows :

NSURLRequest *downloadRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:downloadURL]];
NSURLDownload *downloader = [[NSURLDownload alloc] initWithRequest:downloadRequest delegate:self];

where downloadURL is something like "https://www.abcd.com/path/to/file/abc.zip"

But I keep getting the following NSError in the (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error method :

Error Domain=NSURLErrorDomain Code=-3001 "The operation couldn’t be completed. (NSURLErrorDomain error -3001.)" UserInfo=0x618000060a80 {NSErrorFailingURLStringKey=https://www.abcd.com/path/to/file/abc.zip, NSUnderlyingError=0x618000242010 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -3001.)", NSErrorFailingURLKey=https://www.abcd.com/path/to/file/abc.zip}

What am I doing wrong?

Thanks for your help!

2

2 Answers

1
votes

The error you are receiving is kCFURLErrorCannotOpenFile. You will probably need to capture and deal with the .zip file manually.

1
votes

I solved the issue.

The NSURLDownload object's setDestination method needs the not just the directory path (/xx/yy/zz), but also the filename (/xx/yy/zz/abc.zip).