Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.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中不起作用?_Ios_File_Storyboard_Plist_Nsfilemanager - Fatal编程技术网

文件存在或未检查在ios中不起作用?

文件存在或未检查在ios中不起作用?,ios,file,storyboard,plist,nsfilemanager,Ios,File,Storyboard,Plist,Nsfilemanager,您好,我正在使用以下代码检查文件是否存在于我的文档目录中,但它看起来好像不工作。当我在wifi中运行应用程序时,它将下载plist文件并保存在文档目录中,当我强制关闭该应用程序并关闭wifi后,再次运行,那么它不会检测文档目录中已经存在的文件 这是我的密码 NSString *filename=@"Form.plist"; NSString *filecomponent=[NSString stringWithFormat:@"%@",filename]; NSStr

您好,我正在使用以下代码检查文件是否存在于我的文档目录中,但它看起来好像不工作。当我在wifi中运行应用程序时,它将下载plist文件并保存在文档目录中,当我强制关闭该应用程序并关闭wifi后,再次运行,那么它不会检测文档目录中已经存在的文件

这是我的密码

    NSString *filename=@"Form.plist";
    NSString *filecomponent=[NSString  stringWithFormat:@"%@",filename];

    NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:filecomponent];
    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];
    if(!fileExists){
       if([Connectivity hasConnectivity])
       {
           //Download file again
        //   NSLog(@"%@",[[config objectForKey:@"URL"]valueForKey:@"Form"]);

           [self downloadFile:[[config objectForKey:@"URL"]valueForKey:@"Form"] :filename :identifier :rb];

       }else{
           alert=[[UIAlertView alloc]initWithTitle:@"Alert" message:@"Please check your internet connectivity." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
           [alert show];

       }

    }else{


    rb = [self.storyboard instantiateViewControllerWithIdentifier:@"Form"];

    [self.navigationController pushViewController:rb animated:YES];
    }

如果现在没有internet,它只显示警报,而不是进入内部查看控制器。

将Form.plist文件移动到应用程序包中。然后尝试使用“[[NSBundle mainBundle]pathForResource:@formoftype:@plist];”,将其分配给您的文件路径字符串。@Karthik sivam我们无法将文件写入NSBundle。。它受Apple自身的限制。您的文件路径正确吗?尝试打印出来。@user2990885您当然不能写,但您可以将其移动或手动添加到应用程序包中。chancy:谢谢…路径为空…这就是问题所在