开发者

cocoa objective-c question about saving plist atomically

When you save a plist atomically -

[thisAgentData writeToFile:plistpath atomically:YES];

does that 开发者_如何学JAVAmean if the file exists it will overwrite all the existing data?


Atomically means that your data is saved to a temporary file which is then renamed to the actual path if there was no error during writing. So you will not find an incomplete file at your destination path if the write operation fails (e.g. if the disk is full). Another advantage is that threads that try to read your file while it is written will not face an incomplete file, but get the old one as long as the writing has not finished yet.

But yes, if the operation succeeds, this method will overwrite your destination file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜