使用 NSFileManager 重命名文件时出现奇怪的错误
我曾经使用以下命令来使用各种用户输入的值(BOOL,大多数是字符串)重命名 aplist 文件:
[manager moveItemAtPath:oldPath toPath:newPath error:&error];
并且由于某些原因,在 iOS4+ 中,此问题会出现问题,因此我尝试以下操作:
[1] [manager copyItemAtPath:oldPath toPath:newPath error:&error];
[2] [manager removeItemAtPath:oldPath error:&error];
现在,[1] 复制 plist 和所有数据正确。 (我在注释掉[2]时已经验证过。但是由于某种原因,当我尝试[1]和[2]时,文件/出现/被重命名,但是,只有某些字段丢失,例如I FName和LName 保持不变,而 Phone1、Phone2、Email1、Email2 和 Website 则从新文件中删除
对于我来说,我就是无法弄清楚为什么当我尝试删除旧文件时只保留一些数据。创建新文件后的文件?
非常感谢任何帮助!
我只是想重命名 plist 文件,同时保持所有数据完好无损。
I used to use the following to rename aplist file with various user inputted values (BOOL,Strings mostly):
[manager moveItemAtPath:oldPath toPath:newPath error:&error];
And for some reason in iOS4+ this glitches out, so I Attempt the following:
[1] [manager copyItemAtPath:oldPath toPath:newPath error:&error];
[2] [manager removeItemAtPath:oldPath error:&error];
Now, [1] copies the plist and ALL of the data correctly. (I've verified when commenting out [2]. But for some reason, when I attempt [1] & [2], the file /appears/ renamed, however, there are only certain fields missing, for example I FName and LName stay intact, whereas Phone1,Phone2,Email1,Email2 and Website are removed from the new file.
For the life of me, I just cannot figure out why only some of the data remains when I attempt a removeFileAtPath for the OLD file AFTER the NEW FILE is created?
Any help would be MUCH APPRECIATED!
I just simply want to rename a plist file, while keeping ALL of the data in tact.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)