@@ -171,10 +171,16 @@ return [super init]; } - initWithObject: (id)object { + if (object == nil) { + Class c = [self class]; + [self release]; + @throw [OFInvalidArgumentException exceptionWithClass: c]; + } + return [self initWithObjects: object, nil]; } - initWithObjects: (id)firstObject, ... { @@ -276,11 +282,16 @@ return [self objectAtIndex: index]; } - (size_t)indexOfObject: (id)object { - size_t i, count = [self count]; + size_t i, count; + + if (object == nil) + return OF_NOT_FOUND; + + count = [self count]; for (i = 0; i < count; i++) if ([[self objectAtIndex: i] isEqual: object]) return i; @@ -287,11 +298,16 @@ return OF_NOT_FOUND; } - (size_t)indexOfObjectIdenticalTo: (id)object { - size_t i, count = [self count]; + size_t i, count; + + if (object == nil) + return OF_NOT_FOUND; + + count = [self count]; for (i = 0; i < count; i++) if ([self objectAtIndex: i] == object) return i; @@ -365,12 +381,18 @@ usingSelector: (SEL)selector { void *pool; OFMutableString *ret; id *objects; - size_t i, count = [self count]; + size_t i, count; IMP append; + + if (separator == nil) + @throw [OFInvalidArgumentException + exceptionWithClass: [self class]]; + + count = [self count]; if (count == 0) return @""; if (count == 1) return [[self firstObject] performSelector: selector]; @@ -608,11 +630,17 @@ } #endif - (OFArray*)arrayByAddingObject: (id)object { - OFMutableArray *ret = [[self mutableCopy] autorelease]; + OFMutableArray *ret; + + if (object == nil) + @throw [OFInvalidArgumentException + exceptionWithClass: [self class]]; + + ret = [[self mutableCopy] autorelease]; [ret addObject: object]; [ret makeImmutable]; return ret;