Index: src/OFMutableArray.h ================================================================== --- src/OFMutableArray.h +++ src/OFMutableArray.h @@ -107,10 +107,21 @@ * @param index The index of the object to replace * @param object The replacement object */ - (void)replaceObjectAtIndex: (size_t)index withObject: (ObjectType)object; + +/*! + * @brief Replaces the object at the specified index with the specified object. + * + * This method is the same as @ref replaceObjectAtIndex:withObject:. + * + * This method is also used by the subscripting syntax. + * + * @param index The index of the object to replace + * @param object The replacement object + */ - (void)setObject: (ObjectType)object atIndexedSubscript: (size_t)index; /*! * @brief Replaces the first object that has the same address as the specified Index: src/OFMutableDictionary.h ================================================================== --- src/OFMutableDictionary.h +++ src/OFMutableDictionary.h @@ -61,18 +61,30 @@ - (instancetype)initWithCapacity: (size_t)capacity; /*! * @brief Sets an object for a key. * - * A key can be any object that conforms to the OFCopying protocol. + * A key can be any object that conforms to the @ref OFCopying protocol. * * @param key The key to set * @param object The object to set the key to */ - (void)setObject: (ObjectType)object forKey: (KeyType)key; -- (void)setObject: (ObjectType)object + +/*! + * @brief Sets an object for a key. + * + * A key can be any object that conforms to the @ref OFCopying protocol. + * + * This method is also used by the subscripting syntax. + * + * @param key The key to set + * @param object The object to set the key to. If it is nil, this is equal to + * calling @ref removeObjectForKey:. + */ +- (void)setObject: (nullable ObjectType)object forKeyedSubscript: (KeyType)key; /*! * @brief Removes the object for the specified key from the dictionary. * Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -168,12 +168,15 @@ } - (void)setObject: (id)object forKeyedSubscript: (id)key { - [self setObject: object - forKey: key]; + if (object != nil) + [self setObject: object + forKey: key]; + else + [self removeObjectForKey: key]; } - (void)removeObjectForKey: (id)key { OF_UNRECOGNIZED_SELECTOR