开发者

NSFileManager: Copy a file atomically?

开发者 https://www.devze.com 2023-02-04 20:48 出处:网络
in my iPhone projects, I am currently copying files using NSFileManager\'s -copyItemAtPath:toPath:error: method. However, the docs so not say anything about atomicity, so I might run into trouble if m

in my iPhone projects, I am currently copying files using NSFileManager's -copyItemAtPath:toPath:error: method. However, the docs so not say anything about atomicity, so I might run into trouble if my app tries to read a file that is currently being replaced by another thread. Is there a开发者_开发知识库 way to copy or replace a file atomically? I am searching for something like NSData's -writeDataToFilr:atomically:.


How do you use NSFileManager? According to the docs, it says the following:

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].

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号