I have the following code in an ApplicationDelegate application. My deployment goal is 3.0 and higher, however, I get EXC_BAD_ACCESS when I run the application with the following code on my iPhone with 3.1.3, however, on the simulator with 4.2 it works fine.
This problem is now SOLVED . The code below works and it got EXC_BAD_ACCESS due to NSURLConnection in my code. I will not delete my code if anyone else gets this problem. Thank you for your help.
UPDATE:
File plist:
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Check for report on start?</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Autocheck reports?</string>
<key>Key</key>
<string>FAutoUpdatePrefKey</string>
<key>DefaultValue</key>
<true/>
</dict>
</array>
Applicationdelegate
+ (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];
}
source
share