Crash saving to NSUserDefaults
Crash saving to NSUserDefaults
- Subject: Crash saving to NSUserDefaults
- From: {le_MoJo} <email@hidden>
- Date: Tue, 30 Apr 2002 23:57:57 +0200
I have this code:
- (void)savePrefs
{
[preferences setObject:[locationText stringValue]
forKey:@"CDLocation"];
[preferences setObject:[NSArray arrayWithObjects:
[NSNumber numberWithInt:[switcha state]],
[NSNumber numberWithInt:[switchA state]],
[NSNumber numberWithInt:[switche state]],
[NSNumber numberWithInt:[switchr state]],
[NSNumber numberWithInt:[switchR state]],
[NSNumber numberWithInt:[switchS state]],
[NSNumber numberWithInt:[switchs state]],
nil] forKey:@"Switches"];
[prefs setObject:preferences forKey:@"Prefs"];
}
When I compile and run i get this as soon as the method gets called.
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000
Thread 0 Crashed:
#0 0x706bab68 in objc_msgSend
#1 0x701683f4 in CFEqual
#2 0x70179554 in __CFDictionaryEqual
#3 0x701684e8 in CFEqual
#4 0x7018a130 in writeXMLValue
#5 0x7018a05c in _CFPreferencesDomainSet
#6 0x701a7228 in _CFApplicationPreferencesSet
#7 0x708b2a74 in -[NSUserDefaults setObject:forKey:]
#8 0x00005c88 in -[VCDPrefsController savePrefs]
#9 0x00005954 in -[VCDPrefsController saveButton:]
I have checked, and I'm absolutely sure that everything exists and can
respond to the message I'm sending to it. By using NSLog() I have
determined that it fails precisely after setting the key Switches and
when I try to write it to prefs (my NSUserDefaults, preferences is just
an NSMutableDictionary). What silly little thing am I doing wrong,
please???
I just noticed something. I have two buttons:
- (IBAction)doneButton:(id)sender
{
[self savePrefs];
[saveButton setEnabled:NO];
[changesText setStringValue:@""];
[mainController updateSwitches];
[prefWindows orderOut:self];
}
- (IBAction)saveButton:(id)sender
{
[self savePrefs];
[saveButton setEnabled:NO];
[changesText setStringValue:@""];
}
When savePrefs gets called from doneButton it *does* work and doesn't
crash. But it still crashes when called from saveButton. What can that
be? I'm so lost...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.