Simple NSMutableDictionary Question

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

  1. macrumors 6502

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

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

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #2
    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