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
arrayThe 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
comparatorAn 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
blockThe predicate used to filter the results.
-
Creates a mutable array by repeating the same
itembyrepeatnumber of times. The size of the array is going to be qual torepeat, only consisting ofitemobjects.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
itemThe item to repeat
repeatNumber of times to repeat the
itemparameterReturn Value
A new NSMutableArray instance with the given item repeated
-
Creates a mutable array by taking an initial
arrayand computing the next items by repeatedly putting the result ofblockbyrepeatednumber 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
arrayInitial array
blockThe block to compute the next item in the resulting array
repeatNumber of times to repeat calling the
blockparameterReturn Value
A new NSMutableArray instance with items returned by the block
-
Creates a mutable array by taking an initial
arrayand computing the next items by repeatedly putting the result ofblockby until the block parameteruntilreturns 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
arrayInitial array
blockThe block to compute the next item in the resulting array
untilLogic until the iteration should be repeated. Until the block returns YES, the constructor repeatedly callis the
blockparameterReturn Value
A new NSMutableArray instance with items returned by the block
View on GitHub
Install in Dash
NSMutableArray(FunkyUtilities) Category Reference