Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, your application can access the saved preferences before the <code>synchronize</code> happens, if it is saved before the read cycle happens during the same run session of the application. For accessing the information during subsequent app launches it is necessary that the synchronisation happens.</p> <p>From the Apple docs: <a href="http://developer.apple.com/library/ios/#documentation/cocoa/reference/foundation/Classes/NSUserDefaults_Class/Reference/Reference.html">NSUserDefaults</a></p> <blockquote> <p>NSUserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value. The synchronize method, which is automatically invoked at periodic intervals, keeps the in-memory cache in sync with a user’s defaults database.</p> </blockquote> <p>The <a href="http://developer.apple.com/library/ios/#documentation/cocoa/reference/foundation/Classes/NSUserDefaults_Class/Reference/Reference.html#//apple_ref/doc/uid/20000318-CIHDDEGI">synchronize</a> method writes any modifications to in-memory cache to the disk (plist file in <code>Library/Preferences</code>) and updates the unmodified in-memory cache to the latest on disk. This method gets invoked at periodic intervals, without the app getting notified. </p> <p>From docs again: <code>[NSUserDefaults synchronize]</code></p> <blockquote> <p><strong>Discussion</strong><br> Because this method is automatically invoked at periodic intervals, use this method only if you cannot wait for the automatic synchronization (for example, if your application is about to exit) or if you want to update the user defaults to what is on disk even though you have not made any changes.</p> </blockquote> <p>In my experience, call the <code>synchronize</code> method explicitly when application is going to exit, this ensures that the latest preferences are available on next launch. However, I have also come across scenarios when application crashes before the <code>synchronize</code> happens so the pref are not stored. Your application must be able to handle these scenarios. </p> <p><strong>Additional</strong> <br> Use the NSUserDefaults to store minimal data, do not store huge data. Reason is, the app defaults are loaded during the app launch, if the data to load is huge then the app loading time increases and chances are that the app is killed by the <code>Springboard</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload