本文介绍了在keychains / userdefaults中保存原子属性有什么优点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在NSUserDefaults / keychains中存储一些值有没有原子或非原子属性的任何优势?

For storing some values in NSUserDefaults / keychains is there any advantage of having atomic or non-atomic properties?

推荐答案

之间的区别是,原子要求所有数据必须成功写入,而非原子意味着尽可能写入(即不一定全部

The difference between "atomic" and "non-atomic" is that atomic requires that all of the data must be successfully written while "non-atomic" means "write as much as possible" (i.e. not necessarily all of it).

因此,对于许多事情(例如小数据位),非原子或原子之间没有太大的实际差异。

So for many things (e.g. small bits of data), there's not much of a practical difference between non-atomic or atomic.

但是对于更大的数据块,非原子对原子实际上产生了差异。您需要将写入的数据完全百分百完整,或者您的应用程序是否只处理已写入默认或钥匙串的数据?

But for larger blocks of data, then non-atomic vs. atomic actually makes a difference. Do you need to have the data that's written to be 100% perfect and complete, or can your app handle just some of whatever has been written to default or the keychain?

这篇关于在keychains / userdefaults中保存原子属性有什么优点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 11:00