NSArray(FunkyPrefixedUtilities)
@interface NSArray <__covariant ObjectType>
(FunkyPrefixedUtilities) @end
This extension provides simple and easy to use functional and general utilities for NSArray.
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 counterpartNSArray(FunkyUtilities)
See
Mutable counterpartNSMutableArray(FunkyPrefixedUtilities)
-
Returns whether the condition matches all elements in the array
See
Unprefixed counterpart-[NSArray(FunkyUtilities) all:]
Declaration
Objective-C
- (BOOL)funky_all:(BOOL (^)(ObjectType))block;
Swift
func funky_all(_ block: ((Any?) -> Bool)!) -> Bool
Parameters
block
The condition given as a BOOL expression
Return Value
YES if condition matches all elements, NO otherwise
-
Returns whether the condition matches no elements in the array
See
Unprefixed counterpart-[NSArray(FunkyUtilities) none:]
Declaration
Objective-C
- (BOOL)funky_none:(BOOL (^)(ObjectType))block;
Swift
func funky_none(_ block: ((Any?) -> Bool)!) -> Bool
Parameters
block
The condition given as a BOOL expression
Return Value
NO if condition matches any of the elements, YES otherwise
-
Returns whether the condition matches at least one element in the array
See
Unprefixed counterpart-[NSArray(FunkyUtilities) contains:]
Declaration
Objective-C
- (BOOL)funky_contains:(BOOL (^)(ObjectType))block;
Swift
func funky_contains(_ block: ((Any?) -> Bool)!) -> Bool
Parameters
block
The condition given as a BOOL expression
Return Value
YES if condition matches any of the elements, NO otherwise
-
Returns the number of elements the given condition matches in the array, like if you would filter the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) count:]
Declaration
Objective-C
- (NSUInteger)funky_count:(BOOL (^)(ObjectType))block;
Swift
func funky_count(_ block: ((Any?) -> Bool)!) -> UInt
Parameters
block
The condition given as a BOOL expression
Return Value
Number of occasions where the condition matches in the array
-
Returns a new NSArray instance with the same amount of elements, where each element is transformed to another by returning a new object in the block parameter.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) map:]
Declaration
Objective-C
- (NSArray *)funky_map:(id (^)(ObjectType))block;
Swift
func funky_map(_ block: ((Any?) -> Any?)!) -> [Any]!
Parameters
block
The transformator code which should return a new value based on the existing one.
Return Value
A new NSArray instance where each element is formed by the result of the block calls
-
Returns a new NSArray instance where each element is transformed to another by returning a new object in the block parameter. It ignores the nil parameters returned from the block.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) nilTolerantMap:]
Declaration
Objective-C
- (NSArray *)funky_nilTolerantMap:(id (^)(ObjectType))block;
Swift
func funky_nilTolerantMap(_ block: ((Any?) -> Any?)!) -> [Any]!
Parameters
block
The transformator code which should return a new value based on the existing one.
Return Value
A new NSArray instance where each element is formed by the result of the block calls
-
Same as map, but the block contains the index of the current element.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) mapWithIndex:]
Declaration
Objective-C
- (NSArray *)funky_mapWithIndex:(id (^)(NSUInteger, ObjectType))block;
Swift
func funky_map(index block: ((UInt, Any?) -> Any?)!) -> [Any]!
Parameters
block
The transformator code which should return a new value based on the index and the existing item.
Return Value
A new NSArray instance where each element is formed by the result of the block calls
-
Same as nil-tolerant map, but the block contains the index of the current element.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) nilTolerantMapWithIndex:]
Declaration
Objective-C
- (NSArray *)funky_nilTolerantMapWithIndex:(id (^)(NSUInteger, ObjectType))block;
Swift
func funky_nilTolerantMap(index block: ((UInt, Any?) -> Any?)!) -> [Any]!
Parameters
block
The transformator code which should return a new value based on the index and the existing item.
Return Value
A new NSArray instance where each element is formed by the result of the block calls
-
Returns a new NSArray instance with the same amount of elements, where each element is transformed to another by returning a new object in the block parameter. Same as map, but the result is going to be flattened, so if you return an NSArray any iteration, it is going to be converted into a flat structure, not an array of arrays.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) flatMap:]
Declaration
Objective-C
- (NSArray *)funky_flatMap:(id (^)(ObjectType))block;
Swift
func funky_flatMap(_ block: ((Any?) -> Any?)!) -> [Any]!
Parameters
block
The transformator code which should return a new value based on the existing one.
Return Value
A new NSArray instance where each element is formed by the result of the flattened block calls
-
Same as flatMap, but the block contains the index of the current element.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) flatMapWithIndex:]
Declaration
Objective-C
- (NSArray *)funky_flatMapWithIndex:(id (^)(NSUInteger, ObjectType))block;
Swift
func funky_flatMap(index block: ((UInt, Any?) -> Any?)!) -> [Any]!
Parameters
block
The transformator code which should return a new value based on the index and the existing item.
Return Value
A new NSArray instance where each element is formed by the result of the flattened block calls
-
Returns a new NSArray instance with the element, that are passing the returned expression in the original array.
See
Mutable counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_filter:]
See
Unprefixed counterpart-[NSArray(FunkyUtilities) filtered:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_filtered:(BOOL (^)(ObjectType))block;
Swift
func funky_filtered(_ block: ((Any?) -> Bool)!) -> [Any]!
Parameters
block
The filtering predicate given as a BOOL expression
Return Value
A new NSArray instance where each element is selected from the original one where the block returned YES
-
Flattens the array, meaning that if it consisted of Array items, they are going to be flattened into one flat structure of elements. An array of arrays will transform to an array of elements from each of the previous arrays. This computation is performed deeply, meaning that it contontued flattening elements, until they produce a flat structure.
See
Mutable counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_flattened]
See
Unprefixed counterpart-[NSArray(FunkyUtilities) flattened]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_flattened;
Swift
func funky_flattened() -> [Any]!
Return Value
A new NSArray instance where the elements don’t contain NSArrays
-
Returns a new NSArray instance, in which concatenates the two arrays by putting the existing elements first, and the elements in the provided array after them.
See
Mutable counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_merge:]
See
Unprefixed counterpart-[NSArray(FunkyUtilities) merged:]
Declaration
Objective-C
- (NSArray *)funky_merged:(NSArray *)array;
Swift
func funky_merged(_ array: [Any]!) -> [Any]!
Parameters
array
The other collection to merge with
Return Value
A new NSArray which contains the elements of both arrays (self and the
array
parameter)
-
Calls every element of the array once.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) forEach:]
Declaration
Objective-C
- (void)funky_forEach:(void (^)(ObjectType))block;
Swift
func funky_(forEach block: ((Any?) -> Void)!)
Parameters
block
A block, giving the current item in each iteration.
-
Calls every element of the array once. Same as forEach, but the block contains the index of the current element as well.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) forEachWithIndex:]
Declaration
Objective-C
- (void)funky_forEachWithIndex:(void (^)(NSUInteger, ObjectType))block;
Swift
func funky_forEach(index block: ((UInt, Any?) -> Void)!)
Parameters
block
A block, giving the current item and its index in each iteration.
-
Groups elements to an NSDictionary, where the returned element serves as a key, and the objects as the value. If multiple elements are returned with the same key, this function will use the first matching element.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) groupByUsingFirst:]
Declaration
Objective-C
- (NSDictionary<id, ObjectType> *)funky_groupByUsingFirst: (id (^)(ObjectType))block;
Swift
func funky_groupBy(first block: ((Any?) -> Any?)!) -> [AnyHashable : Any]!
Parameters
block
A block which returns a key (based on the passed element) used as the key in the dictionary for that element.
Return Value
An NSDictionary where keys are produced by the result of the block call, and the values are the original elements
-
Groups elements to an NSDictionary, where the returned element serves as a key, and the objects as the value. If multiple elements are returned with the same key, this function will use the last matching element.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) groupByUsingLast:]
Declaration
Objective-C
- (NSDictionary<id, ObjectType> *)funky_groupByUsingLast: (id (^)(ObjectType))block;
Swift
func funky_groupBy(last block: ((Any?) -> Any?)!) -> [AnyHashable : Any]!
Parameters
block
A block which returns a key (based on the passed element) used as the key in the dictionary for that element.
Return Value
An NSDictionary where keys are produced by the result of the block call, and the values are the original elements
-
Groups elements to an NSDictionary, where the returned element serves as a key, and the objects as the value. The elements in the resulting Dictionary are arrays, so if multiple elements return the same keys, all of them are going to be included in the value.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) associateBy:]
Declaration
Objective-C
- (NSDictionary<id, NSArray<ObjectType> *> *)funky_associateBy: (id (^)(ObjectType))block;
Swift
func funky_associate(by block: ((Any?) -> Any?)!) -> [AnyHashable : [Any]]!
Parameters
block
A block which returns a key (based on the passed element) used as the key in the dictionary.
Return Value
An NSDictionary where keys are produced by the result of the blocks, and the values are an array of original elements
-
Produces an aggregated value based on the elements of the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) reduce:withInitialValue:]
Declaration
Objective-C
- (id)funky_reduce:(id (^)(id, ObjectType))block withInitialValue:(id)start;
Swift
func funky_reduce(_ block: ((Any?, Any?) -> Any?)!, withInitialValue start: Any!) -> Any!
Parameters
start
The value to start with. At first this is going to be the rolling value.
block
The computation logic, which takes the rolling value and the current item and aggregates them using some custom logic.
Return Value
A custom value which is produced by computing all the elements with a custom logic, returned in
block
-
A special use-case of reduce, which summarises the returned double values for each element in the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) sum:]
Declaration
Objective-C
- (double)funky_sum:(double (^)(ObjectType))block;
Swift
func funky_sum(_ block: ((Any?) -> Double)!) -> Double
Parameters
block
A block which returns double value, based on the current element.
Return Value
The sum of all elements, where the numbers are computed are transformed based on the original elements
-
A special use-case of reduce, which takes the average value of the returned double values for each element in the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) average:]
Declaration
Objective-C
- (double)funky_average:(double (^)(ObjectType))block;
Swift
func funky_average(_ block: ((Any?) -> Double)!) -> Double
Parameters
block
A block which returns double value, based on the current element.
Return Value
The average of all elements, where the numbers are computed are transformed based on the original elements
-
A special use-case of reduce, which takes the minimum of the returned double values for each element in the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) minValue:]
Declaration
Objective-C
- (double)funky_minValue:(double (^)(ObjectType))block;
Swift
func funky_minValue(_ block: ((Any?) -> Double)!) -> Double
Parameters
block
A block which returns double value, based on the current element.
Return Value
The minimum of all elements, where the numbers are computed are transformed based on the original elements
-
A special use-case of reduce, which takes the maximum of the returned double values for each element in the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) maxValue:]
Declaration
Objective-C
- (double)funky_maxValue:(double (^)(ObjectType))block;
Swift
func funky_maxValue(_ block: ((Any?) -> Double)!) -> Double
Parameters
block
A block which returns double value, based on the current element.
Return Value
The maximum of all elements, where the numbers are computed are transformed based on the original elements
-
Returns an array with all the minimal value elements in the array, where the minimum was computed by the returned double value for each element in the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) minItems:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_minItems:(double (^)(ObjectType))block;
Swift
func funky_minItems(_ block: ((Any?) -> Double)!) -> [Any]!
Parameters
block
A block which returns double value, based on the current element.
Return Value
The array of elements with the minimal value, where the numbers are computed are transformed based on the original elements
-
Returns an array with all the maximal value elements in the array, where the maximum was computed by the returned double value for each element in the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) maxItems:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_maxItems:(double (^)(ObjectType))block;
Swift
func funky_maxItems(_ block: ((Any?) -> Double)!) -> [Any]!
Parameters
block
A block which returns double value, based on the current element.
Return Value
The array of elements with the maximal value, where the numbers are computed are transformed based on the original elements
-
Returns the first index of the array: 0
See
Unprefixed counterpart-[NSArray(FunkyUtilities) firstIndex]
Declaration
Objective-C
- (NSUInteger)funky_firstIndex;
Swift
func funky_firstIndex() -> UInt
Return Value
the first index of the array
-
Returns the last index of the array: count - 1
See
Unprefixed counterpart-[NSArray(FunkyUtilities) lastIndex]
Declaration
Objective-C
- (NSUInteger)funky_lastIndex;
Swift
func funky_lastIndex() -> UInt
Return Value
the last index of the array
-
Returns the first element, where the predicate matches
See
Unprefixed counterpart-[NSArray(FunkyUtilities) first:]
Declaration
Objective-C
- (id)funky_first:(BOOL (^)(ObjectType))block;
Swift
func funky_first(_ block: ((Any?) -> Bool)!) -> Any!
Parameters
block
The condition provided as a BOOL expression.
Return Value
The first element where the block returns YES
-
Returns the index of the first element, where the predicate matches
See
Unprefixed counterpart-[NSArray(FunkyUtilities) firstIndex:]
Declaration
Objective-C
- (NSUInteger)funky_firstIndex:(BOOL (^)(ObjectType))block;
Swift
func funky_firstIndex(_ block: ((Any?) -> Bool)!) -> UInt
Parameters
block
The condition provided as a BOOL expression.
Return Value
The index of the first element where the block returns YES
-
Returns the last element, where the predicate matches
See
Unprefixed counterpart-[NSArray(FunkyUtilities) last:]
Declaration
Objective-C
- (id)funky_last:(BOOL (^)(ObjectType))block;
Swift
func funky_last(_ block: ((Any?) -> Bool)!) -> Any!
Parameters
block
The condition provided as a BOOL expression.
Return Value
The index of the first element where the block returns YES
-
Returns the index of the last element, where the predicate matches
See
Unprefixed counterpart-[NSArray(FunkyUtilities) lastIndex:]
Declaration
Objective-C
- (NSUInteger)funky_lastIndex:(BOOL (^)(ObjectType))block;
Swift
func funky_lastIndex(_ block: ((Any?) -> Bool)!) -> UInt
Parameters
block
The condition provided as a BOOL expression.
Return Value
The index of the last element where the block returns YES
-
Returns an array of the values where the predicate matches, but only until it’s a consecutive sequence. Once the predicate returns NO, those elements are going to be dropped.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) take:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_take:(BOOL (^)(ObjectType))block;
Swift
func funky_take(_ block: ((Any?) -> Bool)!) -> [Any]!
Parameters
block
The condition provided as a BOOL expression.
Return Value
The first subsequence of elements until the block returns YES
-
Returns an array of the values where the predicate matches, but only the last consecutive sequence of these element. Same as take, but from the end of the array.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) takeLast:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_takeLast:(BOOL (^)(ObjectType))block;
Swift
func funky_takeLast(_ block: ((Any?) -> Bool)!) -> [Any]!
Parameters
block
The condition provided as a BOOL expression.
Return Value
The last subsequence of elements from where the block returns YES
-
Returns an array of the values starting from the given object, not including the object itself. If the given object does not exist in the array, the result is going to be an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromValueExclusive:(id)value;
Swift
func funky_(fromValueExclusive value: Any!) -> [Any]!
Parameters
value
The signaling object.
Return Value
A subsequence of elements starting from the first occurence of the given object
-
Returns an array of the values starting from the given object, including the object itself. If the given object does not exist in the array, the result is going to be an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromValueInclusive:(id)value;
Swift
func funky_(fromValueInclusive value: Any!) -> [Any]!
Parameters
value
The signaling value, which is going to be represent in the array as the first element.
Return Value
A subsequence of elements starting from the first occurence of the given object
-
Returns an array of the values starting from the given index, not including the object at the given index. If the given index does not exist in the array, the result is going to be an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromIndexExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromIndexExclusive:(NSInteger)index;
Swift
func funky_(fromIndexExclusive index: Int) -> [Any]!
Parameters
index
The starting index.
Return Value
A subsequence of elements starting from the given index
-
Returns an array of the values starting from the given index, including the object at the fiven index. If the given index does not exist in the array, the result is going to be an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromIndexInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromIndexInclusive:(NSInteger)index;
Swift
func funky_(fromIndexInclusive index: Int) -> [Any]!
Parameters
index
The signaling index, where the element at the index is going to be represent in the array as the first element.
Return Value
A subsequence of elements starting from the given index
-
Returns an array of the values until the given object, not including the object itself. If the given object does not exist in the array, the result is going to be an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) untilValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_untilValueExclusive:(id)value;
Swift
func funky_(untilValueExclusive value: Any!) -> [Any]!
Parameters
value
The signaling object.
Return Value
A subsequence of elements until the first occurence of the given object
-
Returns an array of the values until the given object, including the object itself. If the given object does not exist in the array, the result is going to be an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) untilValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_untilValueInclusive:(id)value;
Swift
func funky_(untilValueInclusive value: Any!) -> [Any]!
Parameters
value
The signaling value, which is going to be represent in the array as the last element.
Return Value
A subsequence of elements until the first occurence of the given object
-
Returns an array of the values until the given index, not including the object at the given index. If the given index does not exist in the array, the result is going to be an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) untilIndexExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_untilIndexExclusive:(NSInteger)index;
Swift
func funky_(untilIndexExclusive index: Int) -> [Any]!
Parameters
index
The starting index.
Return Value
A subsequence of elements until the given index
-
Returns an array of the values until the given index, including the object at the fiven index. If the given index does not exist in the array, the result is going to be an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) untilIndexInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_untilIndexInclusive:(NSInteger)index;
Swift
func funky_(untilIndexInclusive index: Int) -> [Any]!
Parameters
index
The signaling index, where the element at the index is going to be represent in the array as the last element.
Return Value
A subsequence of elements until the given index
-
Returns an array of the values between the given two input objects, excluding both from the result set. If the starting object does not exist in the array, it’s equivalent to the matching untilValue expression. If the ending object does not exist in the array, it’s equivalent to the matching fromValue expression. If neither one exists, the result is an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromValueExclusive:untilValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromValueExclusive:(id)from untilValueExclusive:(id)until;
Swift
func funky_(fromValueExclusive from: Any!, untilValueExclusive until: Any!) -> [Any]!
Parameters
from
The starting object.
until
The ending object.
-
Returns an array of the values between the given two input objects, excluding
from
, includinguntil
from the result set. If the starting object does not exist in the array, it’s equivalent to the matching untilValue expression. If the ending object does not exist in the array, it’s equivalent to the matching fromValue expression. If neither one exists, the result is an empty NSArray.See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromValueExclusive:untilValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromValueExclusive:(id)from untilValueInclusive:(id)until;
Swift
func funky_(fromValueExclusive from: Any!, untilValueInclusive until: Any!) -> [Any]!
Parameters
from
The starting object.
until
The ending object.
Return Value
A subsequence of elements between the first occurences given objects
-
Returns an array of the values between the given two input objects, including
from
, excludinguntil
from the result set. If the starting object does not exist in the array, it’s equivalent to the matching untilValue expression. If the ending object does not exist in the array, it’s equivalent to the matching fromValue expression. If neither one exists, the result is an empty NSArray.See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromValueInclusive:untilValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromValueInclusive:(id)from untilValueExclusive:(id)until;
Swift
func funky_(fromValueInclusive from: Any!, untilValueExclusive until: Any!) -> [Any]!
Parameters
from
The starting object.
until
The ending object.
Return Value
A subsequence of elements between the first occurences given objects
-
Returns an array of the values between the given two input objects, including both from the result set. If the starting object does not exist in the array, it’s equivalent to the matching untilValue expression. If the ending object does not exist in the array, it’s equivalent to the matching fromValue expression. If neither one exists, the result is an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromValueInclusive:untilValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromValueInclusive:(id)from untilValueInclusive:(id)until;
Swift
func funky_(fromValueInclusive from: Any!, untilValueInclusive until: Any!) -> [Any]!
Parameters
from
The starting object.
until
The ending object.
Return Value
A subsequence of elements between the first occurences given objects
-
Returns an array of the values between the given two indices, excluding both objects (at the given indices) from the result set. If the starting index does not exist in the array, it’s equivalent to the matching untilIndex expression. If the ending index does not exist in the array, it’s equivalent to the matching fromIndex expression. If neither one exists, the result is an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromIndexExclusive:untilValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromIndexExclusive:(NSInteger)from untilIndexExclusive:(NSInteger)until;
Swift
func funky_(fromIndexExclusive from: Int, untilIndexExclusive until: Int) -> [Any]!
Parameters
from
The starting index.
until
The ending index.
Return Value
A subsequence of elements between the first occurences given indices
-
Returns an array of the values between the given two indices, excluding the object at the index
from
, including the one at the indexuntil
from the result set. If the starting index does not exist in the array, it’s equivalent to the matching untilIndex expression. If the ending index does not exist in the array, it’s equivalent to the matching fromIndex expression. If neither one exists, the result is an empty NSArray.See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromIndexExclusive:untilValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromIndexExclusive:(NSInteger)from untilIndexInclusive:(NSInteger)until;
Swift
func funky_(fromIndexExclusive from: Int, untilIndexInclusive until: Int) -> [Any]!
Parameters
from
The starting index.
until
The ending index.
Return Value
A subsequence of elements between the first occurences given indices
-
Returns an array of the values between the given two indices, including the object at the index
from
, excluding the one at the indexuntil
from the result set. If the starting index does not exist in the array, it’s equivalent to the matching untilIndex expression. If the ending index does not exist in the array, it’s equivalent to the matching fromIndex expression. If neither one exists, the result is an empty NSArray.See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromIndexInclusive:untilValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromIndexInclusive:(NSInteger)from untilIndexExclusive:(NSInteger)until;
Swift
func funky_(fromIndexInclusive from: Int, untilIndexExclusive until: Int) -> [Any]!
Parameters
from
The starting index.
until
The ending index.
Return Value
A subsequence of elements between the first occurences given indices
-
Returns an array of the values between the given two indices, including both objects (at the given indices) from the result set. If the starting index does not exist in the array, it’s equivalent to the matching untilIndex expression. If the ending index does not exist in the array, it’s equivalent to the matching fromIndex expression. If neither one exists, the result is an empty NSArray.
See
Unprefixed counterpart-[NSArray(FunkyUtilities) fromIndexInclusive:untilValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_fromIndexInclusive:(NSInteger)from untilIndexInclusive:(NSInteger)until;
Swift
func funky_(fromIndexInclusive from: Int, untilIndexInclusive until: Int) -> [Any]!
Parameters
from
The starting index.
until
The ending index.
Return Value
A subsequence of elements between the first occurences given indices
-
Returns an array where is object is unique, so the resulting array does not contain any duplicates. It checks equality using the
-isEqual:
methodSee
Mutable counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_removeDuplicates]
See
Unprefixed counterpart-[NSArray(FunkyUtilities) unique]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_unique;
Swift
func funky_unique() -> [Any]!
Return Value
A new NSArray consisting of unique objects
-
Returns an array where the items are in a reversed order.
See
Mutable counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_reverse]
See
Unprefixed counterpart-[NSArray(FunkyUtilities) reversed]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_reversed;
Swift
func funky_reversed() -> [Any]!
Return Value
A new NSArray in reverese order compared to the original one
-
Returns an array where the items are shuffled randomly.
See
Mutable counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_shuffle]
See
Unprefixed counterpart-[NSArray(FunkyUtilities) shuffled]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_shuffled;
Swift
func funky_shuffled() -> [Any]!
Return Value
A new NSArray consisting of the original objects in a shuffled order
-
Returns an array sorted using the given comparator.
See
Mutable counterpart-[NSMutableArray(FunkyPrefixedUtilities) funky_sort:]
See
Unprefixed counterpart-[NSArray(FunkyUtilities) sorted:]
Declaration
Objective-C
- (NSArray<ObjectType> *)funky_sorted:(NSComparator)comparator;
Swift
func funky_sorted(_ comparator: Comparator!) -> [Any]!
Parameters
comparator
An NSComparator block to define the sort order.
Return Value
A new NSArray sorted by the comparator
-
Creates an 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
Mutable counterpart+[NSMutableArray(FunkyPrefixedUtilities) funky_arrayWithItem:repeated:]
See
Unprefixed counterpart+[NSArray(FunkyUtilities) arrayWithItem:repeated:]
Declaration
Objective-C
+ (NSArray<ObjectType> *)funky_arrayWithItem:(id)item repeated:(NSUInteger)repeat;
Swift
class func funky_array(withItem item: Any!, repeated repeat: UInt) -> [Any]!
Parameters
item
The item to repeat
repeat
Number of times to repeat the
item
parameterReturn Value
A new NSArray instance with the given item repeated
-
Creates an array by taking an initial
array
and computing the next items by repeatedly putting the result ofblock
byrepeated
number of times.See
Mutable counterpart+[NSMutableArray(FunkyPrefixedUtilities) funky_arrayWithArray:nextItem:repeated:]
See
Unprefixed counterpart+[NSArray(FunkyUtilities) arrayWithArray:nextItem:repeated:]
Declaration
Objective-C
+ (NSArray<ObjectType> *)funky_arrayWithArray:(NSArray<ObjectType> *)array nextItem:(id (^)(NSArray *))block repeated:(NSUInteger)repeat;
Swift
class func funky_array(with array: [Any]!, nextItem block: (([Any]?) -> Any?)!, repeated repeat: UInt) -> [Any]!
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 NSArray instance with items returned by the block
-
Creates an 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
Mutable counterpart+[NSMutableArray(FunkyPrefixedUtilities) funky_arrayWithArray:nextItem:until:]
See
Unprefixed counterpart+[NSArray(FunkyUtilities) arrayWithArray:nextItem:until:]
Declaration
Objective-C
+ (NSArray<ObjectType> *)funky_arrayWithArray:(NSArray<ObjectType> *)array nextItem:(id (^)(NSArray *))block until:(BOOL (^)(NSArray *))until;
Swift
class func funky_array(with array: [Any]!, nextItem block: (([Any]?) -> Any?)!, until: (([Any]?) -> Bool)!) -> [Any]!
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 NSArray instance with items returned by the block