EXC_BAD_ACCESS with NSUserdefaults on iphone
<p>I have the following code in my ApplicationDelegate. My deployment target is 3.0 and upwards, however I get a EXC_BAD_ACCESS when I launch the app with the following code on my iPhone with 3.1.3, however on the simulator which has 4.2 it runs fine. </p>

<p>This problem is now <strong>SOLVED</strong>. The code below is working, and it got a EXC_BAD_ACCESS due to a NSURLConnection in my code. I won't delete my code if anyone else get this problem. Thanks for your help.</p>

<p><strong>UPDATE:</strong>
Plist file:</p>

<pre><code>&lt;dict&gt;
&lt;key&gt;StringsTable&lt;/key&gt;
&lt;string&gt;Root&lt;/string&gt;
&lt;key&gt;PreferenceSpecifiers&lt;/key&gt;
&lt;array&gt;
    &lt;dict&gt;
        &lt;key&gt;Type&lt;/key&gt;
        &lt;string&gt;PSGroupSpecifier&lt;/string&gt;
        &lt;key&gt;Title&lt;/key&gt;
        &lt;string&gt;Check for report on start?&lt;/string&gt;
    &lt;/dict&gt;
    &lt;dict&gt;
        &lt;key&gt;Type&lt;/key&gt;
        &lt;string&gt;PSToggleSwitchSpecifier&lt;/string&gt;
        &lt;key&gt;Title&lt;/key&gt;
        &lt;string&gt;Autocheck reports?&lt;/string&gt;
        &lt;key&gt;Key&lt;/key&gt;
        &lt;string&gt;FAutoUpdatePrefKey&lt;/string&gt;
        &lt;key&gt;DefaultValue&lt;/key&gt;
        &lt;true/&gt;
    &lt;/dict&gt;
&lt;/array&gt;
</code></pre>

<p>
</p>

<p><strong>Applicationdelegate</strong></p>

<pre><code>+ (void)initialize {

NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *pListPath = [path stringByAppendingPathComponent:@"Settings.bundle/Root.plist"];

NSDictionary *pList = [NSDictionary dictionaryWithContentsOfFile:pListPath];

NSMutableArray *prefsArray = [pList objectForKey:@"PreferenceSpecifiers"];
NSMutableDictionary *regDictionary = [NSMutableDictionary dictionary];

for (NSDictionary *dict in prefsArray) {
    NSString *key = [dict objectForKey:@"Key"];
    if(key) {
        id value = [dict objectForKey:@"DefaultValue"];
        [regDictionary setObject:value forKey:key];
    }
}
[[NSUserDefaults standardUserDefaults] registerDefaults:regDictionary];
}
</code></pre>
