NSArray(FunkyUtilities)
@interface NSArray <__covariant ObjectType>
(FunkyUtilities) @end
This extension provides simple and easy to use functional and general utilities for NSArray.
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 counterpartNSArray(FunkyPrefixedUtilities)
See
Mutable counterpartNSMutableArray(FunkyUtilities)
-
Returns whether the condition matches all elements in the array
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_all:]
Declaration
Objective-C
- (BOOL)all:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_none:]
Declaration
Objective-C
- (BOOL)none:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_contains:]
Declaration
Objective-C
- (BOOL)contains:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_count:]
Declaration
Objective-C
- (NSUInteger)count:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_map:]
Declaration
Objective-C
- (NSArray *)map:(id (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_nilTolerantMap:]
Declaration
Objective-C
- (NSArray *)nilTolerantMap:(id (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_mapWithIndex:]
Declaration
Objective-C
- (NSArray *)mapWithIndex:(id (^)(NSUInteger, ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_mapWithIndex:]
Declaration
Objective-C
- (NSArray *)nilTolerantMapWithIndex:(id (^)(NSUInteger, ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_flatMap:]
Declaration
Objective-C
- (NSArray *)flatMap:(id (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_flatMapWithIndex:]
Declaration
Objective-C
- (NSArray *)flatMapWithIndex:(id (^)(NSUInteger, ObjectType))block;
Swift
func 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(FunkyUtilities) filter:]
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_filtered:]
Declaration
Objective-C
- (NSArray<ObjectType> *)filtered:(BOOL (^)(ObjectType))block;
Swift
func 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(FunkyUtilities) flatten]
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_flattened]
Declaration
Objective-C
- (NSArray<ObjectType> *)flattened;
Swift
func 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(FunkyUtilities) merge:]
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_merged:]
Declaration
Objective-C
- (NSArray *)merged:(NSArray *)array;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_forEach:]
Declaration
Objective-C
- (void)forEach:(void (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_forEachWithIndex:]
Declaration
Objective-C
- (void)forEachWithIndex:(void (^)(NSUInteger, ObjectType))block;
Swift
func forEachWithIndex(_ 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_groupByUsingFirst:]
Declaration
Objective-C
- (NSDictionary<id, ObjectType> *)groupByUsingFirst:(id (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_groupByUsingLast:]
Declaration
Objective-C
- (NSDictionary<id, ObjectType> *)groupByUsingLast:(id (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_associateBy:]
Declaration
Objective-C
- (NSDictionary<id, NSArray<ObjectType> *> *)associateBy: (id (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_reduce:withInitialValue:]
Declaration
Objective-C
- (id)reduce:(id (^)(id, ObjectType))block withInitialValue:(id)start;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_sum:]
Declaration
Objective-C
- (double)sum:(double (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_average:]
Declaration
Objective-C
- (double)average:(double (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_minValue:]
Declaration
Objective-C
- (double)minValue:(double (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_maxValue:]
Declaration
Objective-C
- (double)maxValue:(double (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_minItems:]
Declaration
Objective-C
- (NSArray<ObjectType> *)minItems:(double (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_maxItems:]
Declaration
Objective-C
- (NSArray<ObjectType> *)maxItems:(double (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_firstIndex]
Declaration
Objective-C
- (NSUInteger)firstIndex;
Swift
func firstIndex() -> UInt
Return Value
the first index of the array
-
Returns the last index of the array: count - 1
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_lastIndex]
Declaration
Objective-C
- (NSUInteger)lastIndex;
Swift
func lastIndex() -> UInt
Return Value
the last index of the array
-
Returns the first element, where the predicate matches
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_first:]
Declaration
Objective-C
- (id)first:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_firstIndex:]
Declaration
Objective-C
- (NSUInteger)firstIndex:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_last:]
Declaration
Objective-C
- (id)last:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_lastIndex:]
Declaration
Objective-C
- (NSUInteger)lastIndex:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_take:]
Declaration
Objective-C
- (NSArray<ObjectType> *)take:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_takeLast:]
Declaration
Objective-C
- (NSArray<ObjectType> *)takeLast:(BOOL (^)(ObjectType))block;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromValueExclusive:(id)value;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromValueInclusive:(id)value;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromIndexExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromIndexExclusive:(NSInteger)index;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromIndexInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromIndexInclusive:(NSInteger)index;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_untilValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)untilValueExclusive:(id)value;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_untilValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)untilValueInclusive:(id)value;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_untilIndexExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)untilIndexExclusive:(NSInteger)index;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_untilIndexInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)untilIndexInclusive:(NSInteger)index;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromValueExclusive:untilValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromValueExclusive:(id)from untilValueExclusive:(id)until;
Swift
func fromValueExclusive(_ 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, 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromValueExclusive:untilValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromValueExclusive:(id)from untilValueInclusive:(id)until;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromValueInclusive:untilValueExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromValueInclusive:(id)from untilValueExclusive:(id)until;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromValueInclusive:untilValueInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromValueInclusive:(id)from untilValueInclusive:(id)until;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromIndexExclusive:untilIndexExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromIndexExclusive:(NSInteger)from untilIndexExclusive:(NSInteger)until;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromIndexExclusive:untilIndexInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromIndexExclusive:(NSInteger)from untilIndexInclusive:(NSInteger)until;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromIndexInclusive:untilIndexExclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromIndexInclusive:(NSInteger)from untilIndexExclusive:(NSInteger)until;
Swift
func 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
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_fromIndexInclusive:untilIndexInclusive:]
Declaration
Objective-C
- (NSArray<ObjectType> *)fromIndexInclusive:(NSInteger)from untilIndexInclusive:(NSInteger)until;
Swift
func 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(FunkyUtilities) removeDuplicates]
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_unique]
Declaration
Objective-C
- (NSArray<ObjectType> *)unique;
Swift
func 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(FunkyUtilities) reverse]
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_reversed]
Declaration
Objective-C
- (NSArray<ObjectType> *)reversed;
Swift
func 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(FunkyUtilities) shuffle]
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_shuffled]
Declaration
Objective-C
- (NSArray<ObjectType> *)shuffled;
Swift
func 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(FunkyUtilities) sort:]
See
Prefixed counterpart-[NSArray(FunkyPrefixedUtilities) funky_sorted:]
Declaration
Objective-C
- (NSArray<ObjectType> *)sorted:(NSComparator)comparator;
Swift
func 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(FunkyUtilities) arrayWithItem:repeated:]
See
Prefixed counterpart+[NSArray(FunkyPrefixedUtilities) funky_arrayWithItem:repeated:]
Declaration
Objective-C
+ (NSArray<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 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(FunkyUtilities) arrayWithArray:nextItem:repeated:]
See
Prefixed counterpart+[NSArray(FunkyPrefixedUtilities) funky_arrayWithArray:nextItem:repeated:]
Declaration
Objective-C
+ (NSArray<ObjectType> *)arrayWithArray:(NSArray<ObjectType> *)array nextItem:(id (^)(NSArray *))block repeated:(NSUInteger)repeat;
Swift
/*not inherited*/ init!(array: [Any]!, nextItem block: (([Any]?) -> 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 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(FunkyUtilities) arrayWithArray:nextItem:until:]
See
Prefixed counterpart+[NSArray(FunkyPrefixedUtilities) funky_arrayWithArray:nextItem:until:]
Declaration
Objective-C
+ (NSArray<ObjectType> *)arrayWithArray:(NSArray<ObjectType> *)array nextItem:(id (^)(NSArray *))block until:(BOOL (^)(NSArray *))until;
Swift
/*not inherited*/ init!(array: [Any]!, nextItem block: (([Any]?) -> 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 NSArray instance with items returned by the block