@@ -230,11 +230,17 @@ } - (void)replaceObject: (id)oldObject withObject: (id)newObject { - size_t i, count = [self count]; + size_t i, count; + + if (oldObject == nil || newObject == nil) + @throw [OFInvalidArgumentException + exceptionWithClass: [self class]]; + + count = [self count]; for (i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: oldObject]) { [self replaceObjectAtIndex: i withObject: newObject]; @@ -244,11 +250,17 @@ } - (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { - size_t i, count = [self count]; + size_t i, count; + + if (oldObject == nil || newObject == nil) + @throw [OFInvalidArgumentException + exceptionWithClass: [self class]]; + + count = [self count]; for (i = 0; i < count; i++) { if ([self objectAtIndex: i] == oldObject) { [self replaceObjectAtIndex: i withObject: newObject]; @@ -264,11 +276,17 @@ selector: _cmd]; } - (void)removeObject: (id)object { - size_t i, count = [self count]; + size_t i, count; + + if (object == nil) + @throw [OFInvalidArgumentException + exceptionWithClass: [self class]]; + + count = [self count]; for (i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: object]) { [self removeObjectAtIndex: i]; @@ -277,11 +295,17 @@ } } - (void)removeObjectIdenticalTo: (id)object { - size_t i, count = [self count]; + size_t i, count; + + if (object == nil) + @throw [OFInvalidArgumentException + exceptionWithClass: [self class]]; + + count = [self count]; for (i = 0; i < count; i++) { if ([self objectAtIndex: i] == object) { [self removeObjectAtIndex: i];