([NSGArray -initWithObjects:count:]): Raise exception for nil objects.

([NSGArray -objectAtIndex:]): Raise exception when index too high.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@630 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1995-10-22 17:58:57 +00:00
parent 7c98affe14
commit a1e01df688

View file

@ -26,6 +26,7 @@
#include <objects/behavior.h>
#include <objects/Array.h>
#include <objects/ArrayPrivate.h>
#include <Foundation/NSException.h>
@implementation NSGArray
@ -43,6 +44,12 @@
/* This is the designated initializer for NSArray. */
- initWithObjects: (id*)objects count: (unsigned)count
{
int i;
for (i = 0; i < count; i++)
if (objects[i] == nil)
[NSException raise:NSInvalidArgumentException
format:@"Tried to add nil"];
/* "super" call into IndexedCollection */
#if 1
CALL_METHOD_IN_CLASS([IndexedCollection class], initWithType:,
@ -76,7 +83,9 @@
- objectAtIndex: (unsigned)index
{
assert(index < _count); /* xxx should raise NSException instead */
if (index < _count)
[NSException raise:NSRangeException
format:@"Index out of bounds"];
return _contents_array[index].id_u;
}