View Full Version : Simple NSMutableDictionary Question

May 6, 2006, 11:56 PM
What is the difference between these two methods:

- (void)setObject:(id)anObject forKey:(id)aKey

- (void)setValue:(id)value forKey:(NSString *)key


May 7, 2006, 12:10 AM
The main difference is that setValue will accept a nil parameter for the object value (in which case it will remove the key from the dictionary), but setObject won't (it will throw an exception). Also, setValue will only work in Mac OS X 10.3 and higher while setObject works in older versions of Mac OS X. Other than that, they're essentially the same (in fact setValue just calls setObject after checking for a nil parameter).