NSUserDefaults 多久同步一次? [英] How often are NSUserDefaults synchronised?
问题描述
NSUserDefaults
的文档说synchronise
方法会被定期调用,但没有提到调用频率.10 分钟的 Google 搜索没有发现任何信息.
The documentation for NSUserDefaults
says that the synchronise
method is called periodically but does not mention how frequently. 10 minutes of Google searches did not reveal anything.
synchronise
方法的调用频率如何?
How frequently is the synchronise
method called?
推荐答案
这是一个没有公开的实现细节(可能它甚至不是一个恒定的时间间隔).但是,您可以通过在 - [NSUserDefaults synchronize]
上执行一个方法 swizzling 并更改其实现以便每次同步时调用 NSLog()
来自己找到它.
This is an implementation detail which is not disclosed (probably it isn't even a constant time interval). However, you can find it out yourself by performing a method swizzling on - [NSUserDefaults synchronize]
and changing its implementation so that it calls NSLog()
every time it's synchronized.
这篇关于NSUserDefaults 多久同步一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!