NSArray(KSTExtensions)

@interface NSArray<__covariant ObjectType> (KSTExtensions)

/**
 Creates and returns an NSArray with the receiver's objects in reverse order.
 
 @return The reversed array
 */
- (NSArray<ObjectType> *)KST_reversedArray;

/**
 Create and return an array by appending *object* onto the receiver.
 
 @param object The object to append
 @return The new array
 */
- (NSArray<ObjectType> *)KST_arrayByAppendingObject:(ObjectType)object;
/**
 Creates and returns an array by appending the objects from array onto the receiver.
 
 @param array The objects to append
 @return The new array
 */
- (NSArray<ObjectType> *)KST_arrayByAppendingArray:(NSArray<ObjectType> *)array;
/**
 Create and return an array by prepending *object* onto the receiver.
 
 @param object The object to prepend
 @return The new array
 */
- (NSArray<ObjectType> *)KST_arrayByPrependingObject:(ObjectType)object;
/**
 Creates and returns an array by prepending the objects from array onto the receiver.
 
 @param array The objects to prepend
 @return The new array
 */
- (NSArray<ObjectType> *)KST_arrayByPrependingArray:(NSArray<ObjectType> *)array;

/**
 Create and return an array by removing the objects in the provided *array*.
 
 @param array The objects to remove
 @return The new array
 */
- (NSArray<ObjectType> *)KST_arrayByRemovingArray:(NSArray<ObjectType> *)array;

/**
 Creates and returns an NSArray with the receiver's objects.
 
 @return The NSSet created from the receiver
 */
- (NSSet<ObjectType> *)KST_set;
/**
 Creates and returns an NSMutableSet with the receiver's objects.
 
 @return The NSMutableSet created from the receiver
 */
- (NSMutableSet<ObjectType> *)KST_mutableSet;

/**
 Returns an NSOrderedSet with the receiver's objects.
 
 @return The NSOrderedSet
 */
- (NSOrderedSet<ObjectType> *)KST_orderedSet;
/**
 Returns an NSMutableOrderedSet with the receiver's objects.
 
 @return The NSMutableOrderedSet
 */
- (NSMutableOrderedSet<ObjectType> *)KST_mutableOrderedSet;

/**
 Creates and returns a shuffled copy of the receiver.
 
 @return The shuffled NSArray
 */
- (NSArray<ObjectType> *)KST_shuffledArray;

/**
 Returns the object at a random index in the receiver.
 
 @return The random object
 */
- (nullable ObjectType)KST_objectAtRandomIndex;

/**
 Returns the object at the provided *index* if *index* is within the receiver's bounds, otherwise returns nil.
 
 @param index The array index
 @return The object or nil
 */
- (nullable ObjectType)KST_safeObjectAtIndex:(NSUInteger)index;

@end

Undocumented

  • Creates and returns an NSArray with the receiver’s objects in reverse order.

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)KST_reversedArray;

    Return Value

    The reversed array

  • Create and return an array by appending object onto the receiver.

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)KST_arrayByAppendingObject:
        (nonnull ObjectType)object;

    Parameters

    object

    The object to append

    Return Value

    The new array

  • Creates and returns an array by appending the objects from array onto the receiver.

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)KST_arrayByAppendingArray:
        (nonnull NSArray<ObjectType> *)array;

    Parameters

    array

    The objects to append

    Return Value

    The new array

  • Create and return an array by prepending object onto the receiver.

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)KST_arrayByPrependingObject:
        (nonnull ObjectType)object;

    Parameters

    object

    The object to prepend

    Return Value

    The new array

  • Creates and returns an array by prepending the objects from array onto the receiver.

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)KST_arrayByPrependingArray:
        (nonnull NSArray<ObjectType> *)array;

    Parameters

    array

    The objects to prepend

    Return Value

    The new array

  • Create and return an array by removing the objects in the provided array.

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)KST_arrayByRemovingArray:
        (nonnull NSArray<ObjectType> *)array;

    Parameters

    array

    The objects to remove

    Return Value

    The new array

  • Creates and returns an NSArray with the receiver’s objects.

    Declaration

    Objective-C

    - (nonnull NSSet<ObjectType> *)KST_set;

    Return Value

    The NSSet created from the receiver

  • Creates and returns an NSMutableSet with the receiver’s objects.

    Declaration

    Objective-C

    - (nonnull NSMutableSet<ObjectType> *)KST_mutableSet;

    Return Value

    The NSMutableSet created from the receiver

  • Returns an NSOrderedSet with the receiver’s objects.

    Declaration

    Objective-C

    - (nonnull NSOrderedSet<ObjectType> *)KST_orderedSet;

    Return Value

    The NSOrderedSet

  • Returns an NSMutableOrderedSet with the receiver’s objects.

    Declaration

    Objective-C

    - (nonnull NSMutableOrderedSet<ObjectType> *)KST_mutableOrderedSet;

    Return Value

    The NSMutableOrderedSet

  • Creates and returns a shuffled copy of the receiver.

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)KST_shuffledArray;

    Return Value

    The shuffled NSArray

  • Returns the object at a random index in the receiver.

    Declaration

    Objective-C

    - (nullable ObjectType)KST_objectAtRandomIndex;

    Return Value

    The random object

  • Returns the object at the provided index if index is within the receiver’s bounds, otherwise returns nil.

    Declaration

    Objective-C

    - (nullable ObjectType)KST_safeObjectAtIndex:(NSUInteger)index;

    Parameters

    index

    The array index

    Return Value

    The object or nil