iphone - NSFileManager:以原子方式复制文件?

标签 iphone objective-c file-io nsfilemanager

在我的 iPhone 项目中,我目前正在使用 NSFileManager-copyItemAtPath:toPath:error: 方法复制文件。但是,文档没有提及任何关于原子性的内容,因此如果我的应用程序试图读取当前正被另一个线程替换的文件,我可能会遇到麻烦。 有没有办法以原子方式复制或替换文件?我正在搜索类似 NSData-writeDataToFilr:atomically:

最佳答案

你如何使用 NSFileManager?根据docs ,它说了以下内容:

In iOS and Mac OS X v 10.5 and later you should consider using [[NSFileManager alloc] init] rather than the singleton method defaultManager. Instances of NSFileManager are considered thread-safe when created using [[NSFileManager alloc] init].

关于iphone - NSFileManager:以原子方式复制文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4689455/

相关文章:

iphone - 如何嵌套UITabBarController

ios - Xcode 6 刷新 NSUserDefaults

objective-c - 使用特定键的值过滤 NSDictionary 的 NSArray

c - Strtol 未返回正确的 endptr - C

MySQL LOAD XML 耗时太长(系统锁定)

iphone - 比较从相机拍摄的图像与现有图像

iphone - 来自 NSData 的图像未正确加载

iPhone -> NSNumberFormatter - 没有货币代码的价格

ios - UIScrollView setContentOffset 会给scrollview 添加 subview ?

c - 模拟文件系统访问