Ios 保存在文档目录中的数据不显示
我的应用程序将下载的音频和视频存储在文档目录中。应用程序的一些用户面临的问题是,在没有任何特定原因(例如应用程序更新)的情况下,在其设备上下载的内容会消失。要保存文件,我的路径如下Ios 保存在文档目录中的数据不显示,ios,download,filepath,nsdocumentdirectory,nsdocumentdirectory-ios8,Ios,Download,Filepath,Nsdocumentdirectory,Nsdocumentdirectory Ios8,我的应用程序将下载的音频和视频存储在文档目录中。应用程序的一些用户面临的问题是,在没有任何特定原因(例如应用程序更新)的情况下,在其设备上下载的内容会消失。要保存文件,我的路径如下 NSArray *dirPaths; NSString *docsDir; dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUse
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
docsDir = dirPaths[0];
NSString *filepath = [NSString stringWithFormat:@"%@/%@_%@_%@", docsDir,username,audioId,fileName];
[[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil];
我的应用程序中的用户名、audioID和文件名从未更改。所以,剩下的唯一选项是,当应用程序尝试搜索保存的文件时,我的文档目录的路径正在以某种方式发生变化,如中所述。因此,我只想知道我是在思考写作方向,还是在内容消失的背后有其他原因?创建您的文档目录,如下所示:
NSString * docsDir = [[dirPaths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_%@_%@", username, audioId, fileName]];