我正在使用以下代码来检查我的文档目录中是否存在该文件,但它看起来不起作用。当我在wifi中运行app时,它下载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];
}
没有互联网现在只显示警报而不是进入查看控制器。