NSMutableArray(FunkyUtilities)
@interface NSMutableArray <ObjectType>
(FunkyUtilities) @end
This extension provides simple and easy to use functional and general utilities for NSMutableArray.
If you need to prefix the extension methods in this category, you should import NSArray+FunkyPrefixedUtilities.h
, where every utility method is prefixed with the funky_
keyword for compatiblitiy reasons.
See
Prefixed counterpartNSMutableArray(FunkyPrefixedUtilities)
See
Immutable counterpartNSArray(FunkyUtilities)
-
Makes the array structure a squence with flat elements, containing no NSArrays
See
Immutable counterpart-[NSArray(FunkyUtilities) flattened]
See
Prefixed counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_flatten]
Declaration
Objective-C
- (void)flatten;
Swift
func flatten()
-
Puts the containing items (in place) in a reversed order.
See
Immutable counterpart-[NSArray(FunkyUtilities) reversed]
See
Prefixed counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_reverse]
Declaration
Objective-C
- (void)reverse;
Swift
func reverse()
-
Shuffles the containing items (in place) in a random fashion.
See
Immutable counterpart-[NSArray(FunkyUtilities) shuffled]
See
Prefixed counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_shuffle]
Declaration
Objective-C
- (void)shuffle;
Swift
func 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(FunkyUtilities) unique]
See
Prefixed counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_removeDuplicates]
Declaration
Objective-C
- (void)removeDuplicates;
Swift
func 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(FunkyUtilities) merged:]
See
Prefixed counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_merge:]
Declaration
Objective-C
- (void)merge:(NSArray<ObjectType> *)array;
Swift
func merge(_ array: [Any]!)
Parameters
array
The other collection to merge with
-
Sorts the array (in place) using the given comparator.
See
Immutable counterpart-[NSArray(FunkyUtilities) sorted:]
See
Prefixed counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_sort:]
Declaration
Objective-C
- (void)sort:(NSComparator)comparator;
Swift
func 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(FunkyUtilities) filtered:]
See
Prefixed counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_filter:]
Declaration
Objective-C
- (void)filter:(BOOL (^)(ObjectType))block;
Swift
func 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(FunkyUtilities) arrayWithItem:repeated:]
See
Prefixed counterpart+[NSMutableArray(FunkyPrefixedUtilities) funky_arrayWithItem:repeated:]
Declaration
Objective-C
+ (NSMutableArray<ObjectType> *)arrayWithItem:(id)item repeated:(NSUInteger)repeat;
Swift
/*not inherited*/ init!(item: Any!, repeated repeat: UInt)
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(FunkyUtilities) arrayWithArray:nextItem:repeated:]
See
Prefixed counterpart+[NSMutableArray(FunkyPrefixedUtilities) funky_arrayWithArray:nextItem:repeated:]
Declaration
Objective-C
+ (NSMutableArray<ObjectType> *)arrayWithArray:(NSArray<ObjectType> *)array nextItem:(id (^)(NSMutableArray *))block repeated:(NSUInteger)repeat;
Swift
/*not inherited*/ init!(array: [Any]!, nextItem block: ((NSMutableArray?) -> Any?)!, repeated repeat: UInt)
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(FunkyUtilities) arrayWithArray:nextItem:until:]
See
Prefixed counterpart+[NSMutableArray(FunkyPrefixedUtilities) funky_arrayWithArray:nextItem:until:]
Declaration
Objective-C
+ (NSMutableArray<ObjectType> *)arrayWithArray:(NSArray<ObjectType> *)array nextItem:(id (^)(NSMutableArray *))block until:(BOOL (^)(NSArray *))until;
Swift
/*not inherited*/ init!(array: [Any]!, nextItem block: ((NSMutableArray?) -> Any?)!, until: (([Any]?) -> Bool)!)
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