writeToFile:atomically:原子性是什么意思? [英] writeToFile:atomically: what does atomically mean?

查看:473
本文介绍了writeToFile:atomically:原子性是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 writeToFile:atomically:方法中的 atomically:参数是什么$ c> - [NSArray writeToFile:atomically:] 例如)。对于 atomically:,通常是传递 YES ,但我不知道这是什么意思。

I am wondering what the atomically: parameter stands for in the writeToFile:atomically: method (-[NSArray writeToFile:atomically:] for example). It is common to pass YES for atomically:, but I don't know what it means.

推荐答案

原子写入是确保有正确,完整的文件写入或错误的原子写入。没有机会,说,一半的写将工作,然后发生了坏事(丢失的电源,驱动器崩溃等),其余的写失败。它是全有或全无。这通常是你想要的。

An 'atomic write' is one where you are guaranteed to have either a correct, complete write to the file or an error. There's no chance that, say, half of the write will work and then something bad happens (lost power, drive crash, etc) and the rest of the write fails. It's all or nothing. This is generally what you want.

这篇关于writeToFile:atomically:原子性是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆