May 7, 2006, 12:56 AM
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, 01: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).