Simple NSMutableDictionary Question

Discussion in 'Mac Programming' started by MacRumoron, May 6, 2006.

  1. MacRumoron macrumors 6502

    Sep 6, 2005
    What is the difference between these two methods:

    - (void)setObject:(id)anObject forKey:(id)aKey
    - (void)setValue:(id)value forKey:(NSString *)key
  2. HexMonkey Administrator


    Staff Member

    Feb 5, 2004
    New Zealand
    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).

Share This Page