Reputation: 15762
When should NSUserDefault values be written? I have a number of default values that could change throughout the duration of the program. Should I be writing the default values immediately after they change or should I wait till the end, when the application is terminated, to write the default values back?
Upvotes: 0
Views: 190
Reputation: 90127
Set the new values to NSUserDefaults directly after the value has changed. NSUserDefaults keeps its data in memory. So writing will most likely be fast enough.
Just make sure that you don't call synchronize
manually. synchronize
will write the saved defaults to disk, so this will be relatively slow.
The system will call synchronize
from time to time, for example when the app goes into the background.
Upvotes: 1