The NXArray classNXArray represents an array that can store ordered objects. More...
#import <Foundation/Foundation.h>
Instance Methods | |
(id) | - initWithCapacity: |
Initializes a new NXArray instance with the specified capacity. More... | |
(id) | - initWithObjects: |
Initializes an array with a variadic list of objects. More... | |
(unsigned int) | - count |
Returns the number of elements in the array. More... | |
(size_t) | - capacity |
Returns the capacity of the array. More... | |
(id) | - firstObject |
Returns the first object in the array. More... | |
(id) | - lastObject |
Returns the last object in the array. More... | |
(BOOL) | - containsObject: |
Returns YES if the collection contains the specified object. More... | |
(id) | - objectAtIndex: |
Returns the lowest index for an object equivalent to the specified object. More... | |
(unsigned int) | - indexForObject: |
Returns the index for the specified object. More... | |
(BOOL) | - append: |
Appends an object to the end of the array. More... | |
(BOOL) | - insert:atIndex: |
Inserts an object at the specified index in the array. More... | |
(BOOL) | - remove: |
Removes the first occurrence of the specified object from the array. More... | |
(BOOL) | - removeObjectAtIndex: |
Removes the object at the specified index from the array. More... | |
(void) | - removeAllObjects |
Removes all objects from the array. More... | |
(NXString *) | - stringWithObjectsJoinedByString: |
Returns a string representation of the array, with each object separated by a delimiter. More... | |
![]() | |
(id) | - retain |
Increases the retain count of the receiver. More... | |
(void) | - release |
Decreases the retain count of the receiver. More... | |
(id) | - autorelease |
Adds the receiver to the autorelease pool. | |
![]() | |
(void) | - dealloc |
Free resources for an existing instance. | |
(id) | - init |
Initialize the instance, after allocation. More... | |
(Class) | - class |
Returns the class of the instance. More... | |
(Class) | - superclass |
Returns the superclass of the instance. More... | |
(BOOL) | - isEqual: |
Compares the receiver to another object for equality. More... | |
(BOOL) | - isKindOfClass: |
Returns a Boolean value that indicates whether the receiver is an instance of a given class. More... | |
(BOOL) | - conformsTo: |
Checks if the receiver's class conforms to a protocol. More... | |
(NXString *) | - description |
Returns a string that represents the instance. More... | |
![]() | |
(BOOL) | - respondsToSelector: |
Checks if the receiver responds to a selector. More... | |
![]() | |
(NXString *) | - JSONString |
Returns a JSON representation of the instance. More... | |
(size_t) | - JSONBytes |
Returns the appropriate capacity for the JSON representation of the instance. More... | |
Class Methods | |
(NXArray *) | + new |
Returns a new empty NXArray instance. | |
(NXArray *) | + arrayWithCapacity: |
Returns a new NXArray instance with the specified capacity. More... | |
(NXArray *) | + arrayWithObjects: |
Returns a new NXArray instance with the specified objects. More... | |
![]() | |
(id) | + allocWithZone: |
Allocates a new instance of an object in a specific memory zone. More... | |
![]() | |
(void) | + initialize |
Performs one-time initialization for the class. More... | |
(id) | + alloc |
Allocate a new class instance. More... | |
(Class) | + class |
Returns the class object. More... | |
(Class) | + superclass |
Returns the superclass of the class. More... | |
(const char *) | + name |
Returns the name of the class. More... | |
(BOOL) | + conformsTo: |
Checks if the class conforms to a protocol. More... | |
(NXString *) | + description |
Returns a string that represents the class. More... | |
Additional Inherited Members | |
![]() | |
id | _zone |
The memory zone where the object is allocated. | |
unsigned short | _retain |
The retain count of the object. | |
id | _next |
The next object in an autorelease pool. | |
![]() | |
Class | isa |
A pointer to the object's class structure. More... | |
- (BOOL) append: | (id< RetainProtocol, ObjectProtocol >) | object |
Appends an object to the end of the array.
object | The object to append to the array. |
+ (NXArray *) arrayWithCapacity: | (size_t) | capacity |
+ (NXArray *) arrayWithObjects: | (id< RetainProtocol >) | firstObject | |
, | ... | ||
Returns a new NXArray instance with the specified objects.
firstObject | The first object to add to the array, followed by additional objects. |
Takes a variadic list of objects terminated by nil. Objects are added to the array in the order they appear in the argument list. The returned array is autoreleased.
- (size_t) capacity |
Returns the capacity of the array.
Returns the current capacity of the array's internal storage, which may be larger than the actual number of elements in the array. This is useful for understanding how much space is available for adding new elements without requiring reallocation.
Returns YES if the collection contains the specified object.
object | The object to check for containment. |
Recursively checks each element in the collection for equality with the specified object. It will return YES if any element matches, including those in nested arrays and maps. If you wish to check for an object's presence as an element in the array, use the indexForObject:
method instead.
Reimplemented from <CollectionProtocol>.
- (unsigned int) count |
Returns the number of elements in the array.
Reimplemented from <CollectionProtocol>.
- (id) firstObject |
Returns the first object in the array.
- (unsigned int) indexForObject: | (id< ObjectProtocol >) | object |
Returns the index for the specified object.
object | The object to find in the array. |
- (id) initWithCapacity: | (size_t) | capacity |
- (id) initWithObjects: | (id< RetainProtocol >) | firstObject | |
, | ... | ||
Initializes an array with a variadic list of objects.
firstObject | The first object to add to the array, followed by additional objects. |
Takes a variadic list of objects terminated by nil. Objects are added to the array in the order they appear in the argument list.
- (BOOL) insert: | (id< RetainProtocol, ObjectProtocol >) | object | |
atIndex: | (unsigned int) | index | |
Inserts an object at the specified index in the array.
object | The object to insert into the array. |
index | The index at which to insert the object. |
Shifts existing elements at and after the specified index to make room for the new object. If the index is greater than the current count, an exception should be thrown.
- (id) lastObject |
Returns the last object in the array.
- (id) objectAtIndex: | (unsigned int) | index |
Returns the lowest index for an object equivalent to the specified object.
index | The object to find in the array. |
Searches the array from the beginning to the end and returns the lowest index for an object equivalent to the specified object. Two objects are considered equivalent if their isEqual:
method returns YES.
- (BOOL) remove: | (id< RetainProtocol >) | object |
Removes the first occurrence of the specified object from the array.
object | The object to remove from the array. |
Searches the array from the beginning to find the first occurrence of an object that is equal to the specified object (using the isEqual:
method). If found, the object is removed and all subsequent elements are shifted down to fill the gap. The array's count is decremented by one. If the object is not found in the array, the method returns NO and the array remains unchanged.
- (void) removeAllObjects |
Removes all objects from the array.
Clears the array by releasing all objects and resetting the internal data structure. The array's count is set to zero and its capacity remains unchanged.
- (BOOL) removeObjectAtIndex: | (unsigned int) | index |
Removes the object at the specified index from the array.
index | The index of the object to remove. |
Removes the object at the specified index and shifts all subsequent elements down by one position to fill the gap. The array's count is decremented by one.
- (NXString *) stringWithObjectsJoinedByString: | (id< NXConstantStringProtocol >) | delimiter |
Returns a string representation of the array, with each object separated by a delimiter.
delimiter | The string to use as a separator between objects. |
This method does not modify the array's contents or structure.