实际上,我依赖于安全选项的完整文件路径(为此我需要文件路径才能将其存储在钥匙串(keychain)中)。这意味着当我重建应用程序时(或者当它发布到 AppStore 时将获得更新),由于文件路径中的包 ID 更改,这些功能被破坏。
我已经想到了解决这个问题的方法:仅从 Documents 目录(/Documents/.../.../myFile.pdf)而不是完整路径(/var/mobile/.../.. .)。有没有办法做到这一点?
或者,我的问题还有其他解决方案吗?
提前致谢 !
最佳答案
从文档目录中获取文件路径
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *getPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",strFileName]];
关于ios - 从文档目录获取文件路径 - Objective-c iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38746818/