mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Encourage better coding by warning about attempts to remove nil objects
from arrays. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@5131 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b9fe4e75e2
commit
11d14c597d
6 changed files with 88 additions and 32 deletions
|
@ -421,9 +421,15 @@ static SEL eqSel = @selector(isEqual:);
|
|||
|
||||
- (void) removeObject: (id)anObject
|
||||
{
|
||||
unsigned index = _count;
|
||||
unsigned index;
|
||||
|
||||
if (index > 0 && anObject)
|
||||
if (anObject == nil)
|
||||
{
|
||||
NSLog(@"attempt to remove nil object");
|
||||
return;
|
||||
}
|
||||
index = _count;
|
||||
if (index > 0)
|
||||
{
|
||||
BOOL (*imp)(id,SEL,id);
|
||||
|
||||
|
@ -470,8 +476,14 @@ static SEL eqSel = @selector(isEqual:);
|
|||
|
||||
- (void) removeObjectIdenticalTo: (id)anObject
|
||||
{
|
||||
unsigned index = _count;
|
||||
unsigned index;
|
||||
|
||||
if (anObject == nil)
|
||||
{
|
||||
NSLog(@"attempt to remove nil object");
|
||||
return;
|
||||
}
|
||||
index = _count;
|
||||
while (index-- > 0)
|
||||
{
|
||||
if (_contents_array[index] == anObject)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue