-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNSArray+Convenience.h
67 lines (44 loc) · 2.47 KB
/
NSArray+Convenience.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// NSArray+Convenience.h
// Sleep Diary
//
// Created by Alexander Ivanov on 16.10.16.
// Copyright © 2016 Alexander Ivanov. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSArray<ObjectType> (Convenience)
+ (instancetype)arrayWithObject:(id)anObject count:(NSUInteger)count;
+ (instancetype)arrayWithObject:(id)object1 withObject:(id)object2;
+ (instancetype)arrayWithObject:(id)object1 withObject:(id)object2 withObject:(id)object3;
- (NSArray<ObjectType> *)arrayWithRange:(NSRange)range;
- (NSArray<ObjectType> *)arrayWithCount:(NSUInteger)count;
- (NSArray<ObjectType> *)arrayWithIndex:(NSUInteger)index;
- (NSArray<ObjectType> *)arrayByAddingObjectsFromNullableArray:(NSArray<ObjectType> *)otherArray;
- (NSArray<ObjectType> *)arrayByAddingNullableObject:(ObjectType)anObject;
- (NSArray<ObjectType> *)arrayByRemovingObjectsFromArray:(NSArray<ObjectType> *)otherArray;
- (NSArray<ObjectType> *)arrayByRemovingObject:(ObjectType)anObject;
- (NSArray<ObjectType> *)arrayByRemovingObjectAtIndex:(NSUInteger)index;
- (NSArray<ObjectType> *)reversedArray;
- (NSArray<ObjectType> *)sortedArray:(BOOL)descending;
- (NSArray<ObjectType> *)sortedArray;
- (NSArray *)map:(id (^)(ObjectType obj))predicate;
- (NSArray<ObjectType> *)query:(BOOL (^)(ObjectType obj))predicate;
- (NSUInteger)first:(BOOL (^)(ObjectType obj))predicate;
- (ObjectType)firstObject:(BOOL (^)(ObjectType obj))predicate;
- (NSUInteger)last:(BOOL (^)(ObjectType obj))predicate;
- (ObjectType)lastObject:(BOOL (^)(ObjectType obj))predicate;
- (BOOL)all:(BOOL (^)(ObjectType obj))predicate;
- (BOOL)any:(BOOL (^)(ObjectType obj))predicate;
- (ObjectType)one:(BOOL (^)(ObjectType one, ObjectType obj))predicate;
- (NSDictionary *)dictionaryWithKey:(id<NSCopying>(^)(ObjectType obj))keyPredicate value:(id(^)(ObjectType obj, id<NSCopying> key, id val))valPredicate;
- (NSDictionary *)dictionaryWithKey:(id<NSCopying>(^)(ObjectType obj))keyPredicate;
+ (instancetype)arrayFromCount:(NSUInteger)count block:(ObjectType (^)(NSUInteger index))block;
+ (instancetype)arrayFromRange:(NSRange)range block:(ObjectType (^)(NSUInteger index))block;
- (NSString *)componentsJoinedByString:(NSString *)separator block:(NSString *(^)(ObjectType obj))block;
- (BOOL)isEqualToArray:(NSArray<ObjectType> *)otherArray block:(BOOL(^)(ObjectType obj, ObjectType otherObj))predicate;
- (ObjectType)randomObject;
@end
@interface NSMutableArray<ObjectType> (Convenience)
- (ObjectType)fifo; //queue
- (ObjectType)lifo; //stack
@end