Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have done a simple test with your data:</p> <ol> <li><p>add a defaults.plist file to an empty project;</p></li> <li><p>set defaults.plist to contain Alpha/Beta/Charlie keys (as per your example);</p></li> <li><p>use the following code at appDidFinishLaunching time:</p> <pre><code>NSString* path = [[NSBundle mainBundle] pathForResource:@"defaults" ofType:@"plist"]; NSDictionary* factoryPrefs = [NSMutableDictionary dictionaryWithContentsOfFile:path]; [[NSUserDefaults standardUserDefaults] registerDefaults:factoryPrefs]; NSLog(@"Delta Key: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"Delta"]); //-- store some user custom values NSLog(@"Charlie Key %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"Charlie"]); [[NSUserDefaults standardUserDefaults] setObject:@"test" forKey:@"Charlie"]; NSLog(@"Charlie Key %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"Charlie"]); </code></pre></li> <li><p>run the app;</p></li> </ol> <p>Outcome was:</p> <pre><code>2013-02-23 17:59:10.795 JigSaw[14747:c07] Delta Key (null) 2013-02-23 17:59:10.797 JigSaw[14747:c07] Charlie Key { Key = Value; } 2013-02-23 17:59:10.797 JigSaw[14747:c07] Charlie Key test </code></pre> <p>Then, I changed the content of defaults.plist by adding the Delta key (again, as per your example), and built/ran the app again (without deleting it from the device, of course). </p> <p>Outcome was:</p> <pre><code>2013-02-23 18:00:37.840 JigSaw[15040:c07] Delta Key { Key = Value; } 2013-02-23 18:00:37.842 JigSaw[15040:c07] Charlie Key test 2013-02-23 18:00:37.842 JigSaw[15040:c07] Charlie Key test </code></pre> <p>So, it seems that <code>registerDefaults</code> will correctly handle any newly added key when used like in the example above.</p> <p>I tend to think that either you are using <code>registerDefaults</code> incorrectly, or you are doing something elsewhere that is the cause of the crash.</p> <p>At a more general level, apart from testing the app update scenario (which is trivial to suggest after the fact, and we all learned it the hard way, one way or another), the good practice for me would me ensuring that your app does not crash even in the presence of wrong or unforeseen input.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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