Search code examples
iphoneobjective-cioscocoansfilemanager

NSFileManager multiple instances write atomicity


I have a dynamic library which I assume uses an instance of NSFileManager. For my app, I need to write to the same file as the dynamic library using NSFileManager. If the dynamic library's NSFileManager writes to the same file as my NSFileManager does at the same time, which one will win or will both fail to finish writing? The dynamic library is not using the NSFileManager singleton instance.


Solution

  • they will both succeed, if atomic. which file remains on disk will depend on which operation finished last. think of an atomic write as a write to a temporary file, then a rename of the temporary.