NSMutableArray(Extensions) Category Reference

Declared in NSArray+Extensions.h

Overview

General purpose extensions to NSMutableArray.

– transformElementsWithBlock:

Performs the transformBlock on each element, removing the item when nil is returned.

- (void)transformElementsWithBlock:(nonnull id __nullable ( ^ ) ( NSUInteger index , id __nonnull value ))transformBlock

Parameters

transformBlock

The block to run on each element.

Discussion

Performs the transformBlock on each element, removing the item when nil is returned.

Warning: transformBlock must not be nil!

Declared In

NSArray+Extensions.h

– shuffle

Randomly shuffles the elements in the NSArray.

- (void)shuffle

Discussion

Randomly shuffles the elements in the NSArray.

Declared In

NSArray+Extensions.h

– popLastObject

Removes the last element from the NSArray and returns it.

- (nullable id)popLastObject

Return Value

The removed last element of the NSArray.

Discussion

Removes the last element from the NSArray and returns it.

Declared In

NSArray+Extensions.h

– addObjectIfMissing:

Adds an object to the NSArray unless it already exists in the NSArray.

- (BOOL)addObjectIfMissing:(nonnull id)object

Parameters

object

The object to add to the NSArray.

Return Value

Whether the item was added to the NSArray or not.

Discussion

Adds an object to the NSArray unless it already exists in the NSArray.

Declared In

NSArray+Extensions.h

– removeObjectIfExists:

Removes an object from the NSArray unless it doesn’t already exist in the NSArray.

- (BOOL)removeObjectIfExists:(nonnull id)object

Parameters

object

The object to remove from the NSArray.

Return Value

Whether the item was removed from the NSArray or not.

Discussion

Removes an object from the NSArray unless it doesn’t already exist in the NSArray.

Declared In

NSArray+Extensions.h