私のApplicationDelegateには次のコードがあります。私の展開ターゲットは3.0以上ですが、iPhoneを3.1.3で起動するとEXC_BAD_ACCESSが表示されますが、シミュレータ上では4.2が正常に動作します。iphoneのNSUserdefaultsを使用したEXC_BAD_ACCESS
この問題は現在SOLVEDです。以下のコードは動作しており、コード内にNSURLConnectionがあるため、EXC_BAD_ACCESSがあります。他の誰かがこの問題を抱えたら、私は自分のコードを削除しません。ご協力いただきありがとうございます。
UPDATE: 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];
}
はい、あなたは正しいです!それは私のregDictionaryと関係があるものです。しかし、私はまだ何がわかりません。ダミーの値を入力するとエラーがなくなるため、正しい方向に私を指してくれてありがとう。 – LuckyLuke
@ PCheeseのコードで私の答えを更新しました – theChrisKent
残念ながらそれはしませんでした:( – LuckyLuke