我尝试从服务器下载 pdf,这是我的代码
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[GlobalMethod convertURL:[NSString stringWithFormat:@"%@%@",SITE_IMAGE_URL,pview.nameLable.text]]]];
NSString *documentDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
// Add your filename to the directory to create your saved pdf location
NSString *pdfLocation = [documentDirectory stringByAppendingPathComponent:@"test.pdf"];
// TEMPORARY PDF PATH
// Get the Caches directory
NSString *cachesDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
// Add your filename to the directory to create your temp pdf location
NSString *tempPdfLocation = [cachesDirectory stringByAppendingPathComponent:@"test.pdf"];
req.shouldContinueWhenAppEntersBackground = YES;
req.delegate = self;
req.downloadProgressDelegate = pview.progressView;
[req setDidFinishSelector:@selector(requestDone:)];
[req setDidFailSelector:@selector(requestWentWrong:)];
[req setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:pview.nameLable.text,REQ_FILE_NAME, nil]];
[req setTemporaryFileDownloadPath:tempPdfLocation];
[req setDownloadDestinationPath:pdfLocation];
[req startAsynchronous];
当委托设置为 self 时,它没有将文件保存到目标路径,但是当我评论此行时它可以正常工作
req.delegate = self;
我真的需要设置代表我该怎么办?