AFNetworking:我需要自己删除下载的文件吗?

AFNetworking: Do I need to delete downloaded file myself?

我正在使用 AFNetworking 下载 zip 文件。完成后调用此块。

- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable  (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block;

下载完成后,我只需将内容解压缩到我想要的位置。

[SSZipArchive unzipFileAtPath:location toDestination:unzipPath];

关于这个我有两个问题。

1) 需要自己删除NSURL位置的原文件吗?或者系统会自动执行此操作?

2) 我应该return 在此块中做什么?

编辑: 查看代码,看起来我可以在那个块中 return nil 并且 AFNetworking 不会移动文件。但是我应该删除位于位置的原始文件吗?

你问:

  1. Do I need to delete the original file at the NSURL location myself? Or will the system do this automatically?

系统会为您完成。

  1. What exactly am I supposed to return in this block?

标准行为是您将 return NSURL 用于本地位置(例如在 Documents 或 Cache 文件夹中),如果是这样,AFNetworking 会为您将其移动到那里下载完成后。