Index: src/OFMutableArray.h ================================================================== --- src/OFMutableArray.h +++ src/OFMutableArray.h @@ -132,11 +132,11 @@ * @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 + * @brief Replaces all objects that have the same address as the specified * object with the other specified object. * * @param oldObject The object to replace * @param newObject The replacement object */ Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -245,17 +245,13 @@ if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; count = self.count; - for (size_t i = 0; i < count; i++) { - if ([self objectAtIndex: i] == oldObject) { + for (size_t i = 0; i < count; i++) + if ([self objectAtIndex: i] == oldObject) [self replaceObjectAtIndex: i withObject: newObject]; - - return; - } - } } - (void)removeObjectAtIndex: (size_t)idx { OF_UNRECOGNIZED_SELECTOR Index: tests/OFMutableArrayTests.m ================================================================== --- tests/OFMutableArrayTests.m +++ tests/OFMutableArrayTests.m @@ -86,15 +86,18 @@ - (void)testReplaceObjectIdenticalToWithObject { [_mutableArray insertObject: [[cArray[1] mutableCopy] autorelease] atIndex: 1]; + [_mutableArray insertObject: [[cArray[1] mutableCopy] autorelease] + atIndex: 4]; [_mutableArray replaceObjectIdenticalTo: cArray[1] withObject: cArray[0]]; OTAssertEqualObjects(_mutableArray, - ([OFArray arrayWithObjects: @"Foo", @"Bar", @"Foo", @"Baz", nil])); + ([OFArray arrayWithObjects: @"Foo", @"Bar", @"Foo", @"Baz", @"Bar", + nil])); } - (void)testReplaceObjectAtIndexWithObject { [_mutableArray replaceObjectAtIndex: 1