【发布时间】:2010-05-29 07:12:58
【问题描述】:
我正在构建一个允许用户选择或拍照的应用程序,然后将其以 jpeg 格式保存到应用程序的文档目录中。一切正常,但是,我意识到每次在设备上构建和运行 Xcode 项目时,都会重新安装应用程序,从而创建一个新的文档目录路径。有什么方法可以在每次安装应用时保留路径?
这是我用来生成要保存的文档目录路径的代码:
NSArray *thePathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *finalPath = [[thePathArray objectAtIndex:0] stringByAppendingPathComponent:@"user_image.jpg"];
有没有更好的方法来做到这一点?我可以使用相对路径吗?还是没有真正的解决方案,因为每次通过 Xcode 构建时都会重新安装整个应用程序?
谢谢, 豪伊
【问题讨论】:
标签: iphone xcode file directory installation