NSMutableArray(FunkyPrefixedUtilities)
@interface NSMutableArray <ObjectType>
(FunkyPrefixedUtilities) @end
This extension provides simple and easy to use functional and general utilities for NSMutableArray.
All the methods in this category are prefixed with the funky_
keyword for compatibility reasons. If you prefer unprefixed utilities, you should import NSArray+FunkyUtilities.h
.
See
Unprefixed counterpartNSMutableArray(FunkyUtilities)
See
Immutable counterpartNSArray(FunkyPrefixedUtilities)
-
Makes the array structure a squence with flat elements, containing no NSArrays
See
Immutable counterpart-[NSArray(FunkyPrefixedUtilities) funky_flattened]
See
Unprefixed counterpart-[NSMutableArray(FunkyUtilities) flatten]
Declaration
Objective-C
- (void)funky_flatten;
Swift
func funky_flatten()
-
Puts the containing items (in place) in a reversed order.
See
Immutable counterpart-[NSArray(FunkyPrefixedUtilities) funky_reversed]
See
Unprefixed counterpart-[NSMutableArray(FunkyUtilities) reverse]
Declaration
Objective-C
- (void)funky_reverse;
Swift
func funky_reverse()
-
Shuffles the containing items (in place) in a random fashion.
See
Immutable counterpart-[NSArray(FunkyPrefixedUtilities) funky_shuffled]
See
Unprefixed counterpart-[NSMutableArray(FunkyUtilities) shuffle]
Declaration
Objective-C
- (void)funky_shuffle;
Swift
func funky_shuffle()
-
Makes the array unique (in place) by removing the duplicated items from the containing items. The method does this keeping the first occurence and removes the further duplications. It checks equality using the
-isEqual:
methodSee
Immutable counterpart-[NSArray(FunkyPrefixedUtilities) funky_unique]
See
Unprefixed counterpart-[NSMutableArray(FunkyUtilities) removeDuplicates]
Declaration
Objective-C
- (void)funky_removeDuplicates;
Swift
func funky_removeDuplicates()
-
Concatenates the current array (in place) with the one given in the parameter. It does this by putting the existing elements first, and the elements in the provided array afterwards.
See
Immutable counterpart-[NSArray(FunkyPrefixedUtilities) funky_merged:]
See
Unprefixed counterpart-[NSMutableArray(FunkyUtilities) merge:]
Declaration
Objective-C
- (void)funky_merge:(NSArray<ObjectType> *)array;
Swift
func funky_merge(_ array: [Any]!)
Parameters
array
The other collection to merge with
-
Sorts the array (in place) using the given comparator.
See
Immutable counterpart-[NSArray(FunkyPrefixedUtilities) funky_sorted:]
See
Unprefixed counterpart-[NSMutableArray(FunkyUtilities) sort:]
Declaration
Objective-C
- (void)funky_sort:(NSComparator)comparator;
Swift
func funky_sort(_ comparator: Comparator!)
Parameters
comparator
An NSComparator block to define the sort order.
-
Filters the array using the given predicate, keeping the elements that are passing the test.
See
Immutable counterpart-[NSArray(FunkyPrefixedUtilities) funky_filtered:]
See
Unprefixed counterpart-[NSMutableArray(FunkyUtilities) filter:]
Declaration
Objective-C
- (void)funky_filter:(BOOL (^)(ObjectType))block;
Swift
func funky_filter(_ block: ((Any?) -> Bool)!)
Parameters
block
The predicate used to filter the results.
-
Creates a mutable array by repeating the same
item
byrepeat
number of times. The size of the array is going to be qual torepeat
, only consisting ofitem
objects.See
Immutable counterpart+[NSArray(FunkyPrefixedUtilities) funky_arrayWithItem:repeated:]
See
Unprefixed counterpart+[NSMutableArray(FunkyUtilities) arrayWithItem:repeated:]
Declaration
Objective-C
+ (NSMutableArray<ObjectType> *)funky_arrayWithItem:(id)item repeated:(NSUInteger)repeat;
Swift
class func funky_array(withItem item: Any!, repeated repeat: UInt) -> NSMutableArray!
Parameters
item
The item to repeat
repeat
Number of times to repeat the
item
parameterReturn Value
A new NSMutableArray instance with the given item repeated
-
Creates a mutable array by taking an initial
array
and computing the next items by repeatedly putting the result ofblock
byrepeated
number of times.See
Immutable counterpart+[NSArray(FunkyPrefixedUtilities) funky_arrayWithArray:nextItem:repeated:]
See
Unprefixed counterpart+[NSMutableArray(FunkyUtilities) arrayWithArray:nextItem:repeated:]
Declaration
Objective-C
+ (NSMutableArray<ObjectType> *) funky_arrayWithArray:(NSArray<ObjectType> *)array nextItem:(id (^)(NSMutableArray *))block repeated:(NSUInteger)repeat;
Swift
class func funky_array(with array: [Any]!, nextItem block: ((NSMutableArray?) -> Any?)!, repeated repeat: UInt) -> NSMutableArray!
Parameters
array
Initial array
block
The block to compute the next item in the resulting array
repeat
Number of times to repeat calling the
block
parameterReturn Value
A new NSMutableArray instance with items returned by the block
-
Creates a mutable array by taking an initial
array
and computing the next items by repeatedly putting the result ofblock
by until the block parameteruntil
returns YES.See
Immutable counterpart+[NSArray(FunkyPrefixedUtilities) funky_arrayWithArray:nextItem:until:]
See
Unprefixed counterpart+[NSMutableArray(FunkyUtilities) arrayWithArray:nextItem:until:]
Declaration
Objective-C
+ (NSMutableArray<ObjectType> *) funky_arrayWithArray:(NSArray<ObjectType> *)array nextItem:(id (^)(NSMutableArray *))block until:(BOOL (^)(NSArray *))until;
Swift
class func funky_array(with array: [Any]!, nextItem block: ((NSMutableArray?) -> Any?)!, until: (([Any]?) -> Bool)!) -> NSMutableArray!
Parameters
array
Initial array
block
The block to compute the next item in the resulting array
until
Logic until the iteration should be repeated. Until the block returns YES, the constructor repeatedly callis the
block
parameterReturn Value
A new NSMutableArray instance with items returned by the block