diff --git a/ChangeLog b/ChangeLog index ebc3d8cf5..1998ecdc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-10-31 Richard Frith-Macdonald + + * Source/NSUserDefaults.m: ([setObject:forKey:]) when given a nil + value to set, remove any existing object for the key. Fix for + MacOS-X compatibility (bug #10743). + 2004-10-29 Matt Rice * Source/Additions/GSObjCRuntime.m (GSObjCAllSubclassesOfClass, diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 05ad463d9..5eeafcba7 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -1194,23 +1194,23 @@ static BOOL isPlistObject(id o) * if this is the first change to a persistent-domain since the * last -synchronize. *

+ * If value is nil, this is equivalent to the -removeObjectForKey: method. */ - (void) setObject: (id)value forKey: (NSString*)defaultName { NSMutableDictionary *dict; id obj; + if (value == nil) + { + [self removeObjectForKey: defaultName]; + } if ([defaultName isKindOfClass: [NSString class]] == NO || [defaultName length] == 0) { [NSException raise: NSInvalidArgumentException format: @"attempt to set object with bad key (%@)", defaultName]; } - if (value == nil) - { - [NSException raise: NSInvalidArgumentException - format: @"attempt to set nil object for key (%@)", defaultName]; - } if (isPlistObject(value) == NO) { [NSException raise: NSInvalidArgumentException