Index: src/OFMutableDictionary.h ================================================================== --- src/OFMutableDictionary.h +++ src/OFMutableDictionary.h @@ -87,10 +87,18 @@ /*! * @brief Removes all objects. */ - (void)removeAllObjects; +/*! + * @brief Adds the entries from the specified dictionary. + * + * @param dictionary The dictionary whose entries should be added + */ +- (void)addEntriesFromDictionary: + (OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary; + #ifdef OF_HAVE_BLOCKS /*! * @brief Replaces each object with the object returned by the block. * * @param block The block which returns a new object for each object Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -191,10 +191,25 @@ - copy { return [[OFDictionary alloc] initWithDictionary: self]; } + +- (void)addEntriesFromDictionary: (OFDictionary *)dictionary +{ + void *pool = objc_autoreleasePoolPush(); + OFEnumerator *keyEnumerator = [dictionary keyEnumerator]; + OFEnumerator *objectEnumerator = [dictionary objectEnumerator]; + id key, object; + + while ((key = [keyEnumerator nextObject]) != nil && + (object = [objectEnumerator nextObject]) != nil) + [self setObject: object + forKey: key]; + + objc_autoreleasePoolPop(pool); +} #ifdef OF_HAVE_BLOCKS - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block { [self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,