mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
([NSArray -lastObject]): Don't assert count; just return nil if it's
empty. ([NSMutableArray -removeLastObject]): Don't assert count; raise NSRangeError if it's empty. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1314 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6298e0f17a
commit
82eb5732bd
1 changed files with 6 additions and 3 deletions
|
@ -294,8 +294,9 @@ static Class NSMutableArray_concrete_class;
|
|||
- lastObject
|
||||
{
|
||||
int count = [self count];
|
||||
assert(count); /* xxx should raise an NSException instead */
|
||||
return [self objectAtIndex:count-1];
|
||||
if (count == 0)
|
||||
return nil;
|
||||
return [self objectAtIndex: count-1];
|
||||
}
|
||||
|
||||
- (void) makeObjectsPerform: (SEL)aSelector
|
||||
|
@ -495,7 +496,9 @@ static Class NSMutableArray_concrete_class;
|
|||
- (void) removeLastObject
|
||||
{
|
||||
int count = [self count];
|
||||
assert(count); /* xxx should raise an NSException instead */
|
||||
if (count == 0)
|
||||
[NSException raise: NSRangeException
|
||||
format: @"Trying to remove from an empty array."];
|
||||
[self removeObjectAtIndex:count-1];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue