mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 17:41:05 +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
336e25cf9f
commit
00e53dbf51
1 changed files with 6 additions and 3 deletions
|
@ -294,8 +294,9 @@ static Class NSMutableArray_concrete_class;
|
||||||
- lastObject
|
- lastObject
|
||||||
{
|
{
|
||||||
int count = [self count];
|
int count = [self count];
|
||||||
assert(count); /* xxx should raise an NSException instead */
|
if (count == 0)
|
||||||
return [self objectAtIndex:count-1];
|
return nil;
|
||||||
|
return [self objectAtIndex: count-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) makeObjectsPerform: (SEL)aSelector
|
- (void) makeObjectsPerform: (SEL)aSelector
|
||||||
|
@ -495,7 +496,9 @@ static Class NSMutableArray_concrete_class;
|
||||||
- (void) removeLastObject
|
- (void) removeLastObject
|
||||||
{
|
{
|
||||||
int count = [self count];
|
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];
|
[self removeObjectAtIndex:count-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue