mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Add check for nil. Force use of subclass init methods
This commit is contained in:
parent
4edcc3f697
commit
d20efecead
2 changed files with 20 additions and 23 deletions
|
@ -161,7 +161,7 @@ static Class mutableSetClass;
|
|||
return [self count];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
- (instancetype) init
|
||||
{
|
||||
return [self initWithObjects: NULL count: 0];
|
||||
}
|
||||
|
@ -280,12 +280,19 @@ static Class mutableSetClass;
|
|||
- (void) insertObject: (id)object atIndex: (NSUInteger)index
|
||||
{
|
||||
GSIArrayItem item;
|
||||
if([self containsObject: object] == NO)
|
||||
if(object == nil)
|
||||
{
|
||||
item.obj = object;
|
||||
GSIArrayInsertItem(&array, item, index);
|
||||
RETAIN(object);
|
||||
_version++;
|
||||
NSWarnLog(@"Attempt to insert nil object");
|
||||
}
|
||||
else
|
||||
{
|
||||
if([self containsObject: object] == NO)
|
||||
{
|
||||
item.obj = object;
|
||||
GSIArrayInsertItem(&array, item, index);
|
||||
RETAIN(object);
|
||||
_version++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -506,12 +506,8 @@ static SEL rlSel;
|
|||
- (instancetype) initWithObjects:(const id [])objects // required override.
|
||||
count:(NSUInteger)count
|
||||
{
|
||||
self = [self init];
|
||||
if(self != nil)
|
||||
{
|
||||
// Need proper implementation in subclass since that is where data will be stored.
|
||||
}
|
||||
return self;
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (instancetype) initWithOrderedSet:(NSOrderedSet *)aSet
|
||||
|
@ -622,12 +618,8 @@ static SEL rlSel;
|
|||
|
||||
- (instancetype) init
|
||||
{
|
||||
self = [super init];
|
||||
if(self == nil)
|
||||
{
|
||||
NSLog(@"NSOrderedSet not allocated.");
|
||||
}
|
||||
return self;
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSUInteger) count // required override
|
||||
|
@ -1068,13 +1060,11 @@ static SEL rlSel;
|
|||
// Key value coding support
|
||||
- (void) setValue: (id)value forKey: (NSString*)key
|
||||
{
|
||||
NSUInteger i;
|
||||
NSUInteger count = [self count];
|
||||
volatile id object = nil;
|
||||
NSEnumerator *e = [self objectEnumerator];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
while((object = [e nextObject]) != nil)
|
||||
{
|
||||
object = [self objectAtIndex: i];
|
||||
[object setValue: value
|
||||
forKey: key];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue