Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios asihttprequest仅在尚未存储时下载_Ios_File_If Statement_Download_Asihttprequest - Fatal编程技术网

Ios asihttprequest仅在尚未存储时下载

Ios asihttprequest仅在尚未存储时下载,ios,file,if-statement,download,asihttprequest,Ios,File,If Statement,Download,Asihttprequest,我正在使用ASIHTTPRequest加载和检索文件。它已经可以工作了,但是现在我正在尝试破坏下载,因为它已经被存储了。我不知道如何实现这个问题。我想用一个if子句来解决这个问题:如果文件没有被缓存,请下载它,否则会中断。你介意帮我写一个合适的Objective-C代码吗?我有文件路径,如果我需要它,那么比较或查看该文件 提前谢谢 伪代码: -(IBAction) download : (id) sender { if (data1.pdf) { // t

我正在使用
ASIHTTPRequest
加载和检索文件。它已经可以工作了,但是现在我正在尝试破坏下载,因为它已经被存储了。我不知道如何实现这个问题。我想用一个if子句来解决这个问题:如果文件没有被缓存,请下载它,否则会中断。你介意帮我写一个合适的Objective-C代码吗?我有文件路径,如果我需要它,那么比较或查看该文件

提前谢谢

伪代码:

        -(IBAction) download : (id) sender {
    if (data1.pdf) { 
       // the download algorithm
    }
    else 
       break;
}

如果您的意思是如何检查文件是否存储在设备的documents目录中,则可以使用:

NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* file = [documentsPath stringByAppendingPathComponent:@"data.pdf"];
if ([[NSFileManager defaultManager] fileExistsAtPath:file]) {
   ...

这不是问题的答案;但是ASIHTTPRequest项目已经不在开发中了,开发人员还有其他选择。啊,谢谢!我在cachesdirectory中加载了它,但应该是类似的,我将尝试:)