我想在我的 iPhone 应用程序中保存一个 .txt 文件,但我希望它能够持续存在,即使应用程序被卸载并重新安装,我仍然可以访问它。
我曾尝试将文件保存在 iPhone 的硬盘上,但始终无法正常工作。
这适用于模拟器:
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
//NSString *dataFile= @"/Users/rajesh/Library/Application Support/iPhone Simulator/4.2/tmp/myfile.dat"; //on simulator
NSData *databuffer;
databuffer = [textBox.text dataUsingEncoding: NSASCIIStringEncoding];
[filemgr createFileAtPath: dataFile contents: databuffer attributes:nil];
[filemgr release];
我在设备上使用它:
NSString *dataFile= @"/var/mobile/Applications/temp/myfile.dat"; //on device
但它不起作用。