mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Added new method for MacOS-X compatibility.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14342 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
02fb142696
commit
fb17f2455d
3 changed files with 56 additions and 16 deletions
|
@ -5,7 +5,8 @@
|
|||
* Source/NSUserDefaults.m: Use distributed lock to ensure that there
|
||||
is no possible window when the defaults file is invalid ... not all
|
||||
systems guarantee that the rename() system call is atomic.
|
||||
|
||||
* Source/NSArray.m: New MacOS-X method ([-initWithArray:copyItems:])
|
||||
|
||||
2002-08-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/WindowsFileHandle.m: Removed ... no longer used.
|
||||
|
|
|
@ -50,6 +50,9 @@
|
|||
- (unsigned) indexOfObjectIdenticalTo: (id)anObject;
|
||||
- (unsigned) indexOfObjectIdenticalTo: (id)anObject inRange: (NSRange)aRange;
|
||||
- (id) initWithArray: (NSArray*)array;
|
||||
#ifndef STRICT_OPENSTEP
|
||||
- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy;
|
||||
#endif
|
||||
- (id) initWithContentsOfFile: (NSString*)file;
|
||||
- (id) initWithObjects: firstObject, ...;
|
||||
- (id) initWithObjects: (id*)objects count: (unsigned)count; // Primitive
|
||||
|
|
|
@ -459,26 +459,59 @@ static SEL rlSel;
|
|||
}
|
||||
|
||||
/**
|
||||
* Initialize the array with the content of anArray. The order is preserved.
|
||||
* <br />May change the value of self before returning it.
|
||||
* Initialize the receiver with the contents of array.
|
||||
* The order of array is preserved.<br />
|
||||
* If shouldCopy is YES then the objects are copied
|
||||
* rather than simply retained.<br />
|
||||
* Invokes -initWithObjects:count:
|
||||
*/
|
||||
- (id) initWithArray: (NSArray*)array
|
||||
- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy
|
||||
{
|
||||
unsigned c;
|
||||
unsigned c = [array count];
|
||||
id objects[c];
|
||||
|
||||
c = [array count];
|
||||
{
|
||||
id objects[c];
|
||||
[array getObjects: objects];
|
||||
if (shouldCopy == YES)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
[array getObjects: objects];
|
||||
self = [self initWithObjects: objects count: c];
|
||||
}
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
objects[i] = [objects[i] copy];
|
||||
}
|
||||
self = [self initWithObjects: objects count: c];
|
||||
#if GS_WITH_GC == 0
|
||||
while (i > 0)
|
||||
{
|
||||
[objects[--i] release];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
self = [self initWithObjects: objects count: c];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the array by decoding from an archive.
|
||||
* <br />May change the value of self before returning it.
|
||||
* Initialize the receiver with the contents of array.
|
||||
* The order of array is preserved.<br />
|
||||
* Invokes -initWithObjects:count:
|
||||
*/
|
||||
- (id) initWithArray: (NSArray*)array
|
||||
{
|
||||
unsigned c = [array count];
|
||||
id objects[c];
|
||||
|
||||
[array getObjects: objects];
|
||||
self = [self initWithObjects: objects count: c];
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the array by decoding from an archive.<br />
|
||||
* Invokes -initWithObjects:count:
|
||||
*/
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
|
@ -496,7 +529,9 @@ static SEL rlSel;
|
|||
return [self initWithObjects: contents count: count];
|
||||
}
|
||||
else
|
||||
return [self initWithObjects: 0 count: 0];
|
||||
{
|
||||
return [self initWithObjects: 0 count: 0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -548,8 +583,9 @@ static SEL rlSel;
|
|||
}
|
||||
|
||||
/** <init />
|
||||
* Initialize the array with count objects.
|
||||
* <br />May change the value of self before returning it.
|
||||
* Initialize the array with count objects.<br />
|
||||
* Retains each object placed in the array.<br />
|
||||
* Like all initializers, may change the value of self before returning it.
|
||||
*/
|
||||
- (id) initWithObjects: (id*)objects count: (unsigned)count
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue