/
Categories.h
85 lines (69 loc) · 2.5 KB
/
Categories.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// Categories.h
// IMLocation
//
// Created by Vincent Gable on 5/28/07.
// Copyright 2007 Vincent Gable. All rights reserved.
//
#import <Foundation/Foundation.h>
#pragma mark UUID
@interface NSString (UUID)
//returns a new string built from a new UUID.
+ (NSString*) stringWithUUID;
@end
@interface NSString (RangeAvoidance)
- (BOOL) hasSubstring:(NSString*)substring;
- (NSString*) substringAfterSubstring:(NSString*)substring;
//Note: -isCaseInsensitiveLike is probably a better alternitive if it's avalible.
- (BOOL) isEqualToStringIgnoringCase:(NSString*)otherString;
@end
#pragma mark Misc
@interface NSObject (VTPGExtensions)
+ (id) make;
@end
@interface NSString (IndempotentPercentEscapes)
//uses UTF8 encoding, behavior is undefined if for other encodings.
- (NSString*) stringByAddingPercentEscapesOnce;
- (NSString*) stringByReplacingPercentEscapesOnce;
@end
@interface NSMutableArray(ArrayQueue)
- (id)takeObject;
@end
@interface NSMutableArray (ArrayStack)
- (id) pop;
@end
@interface NSURL (IsEqualTesting)
- (BOOL) isEqualToURL:(NSURL*)otherURL;
@end
@interface NSBundle (VTPGExtensions)
- (NSString*) bundleVersion;
- (NSURL*) URLForResource:(NSString *)name ofType:(NSString *)ext;
@end
#pragma mark HigherOrderOperations
@interface NSObject (HigherOrderOperations)
//implements the visitor pattern
//returns self, so it can be chained
- (id) performSelector:(SEL)oneArgumentSelector withEachItemOf:(id)container;
//analogus to map
- (NSArray*) nonNilResultsOfPerformingSelector:(SEL)oneArgumentSelector withEachItemOf:(id)container;
- (NSMutableArray*) mutableNonNilResultsOfPerformingSelector:(SEL)oneArgumentSelector withEachItemOf:(id)container;
@end
@interface NSArray (HigherOrderOperations)
- (NSMutableArray*) mutableNonNilResultsOfApplyingSelector:(SEL)sel;
- (NSMutableArray*) mutableNonNilResultsOfApplyingSelector:(SEL)sel withObject:arg;
- (NSMutableArray*) mutableResultsOfApplyingSelector:(SEL)sel withObject:arg;
- (NSArray*) resultsOfApplyingSelector:(SEL)sel withObject:arg;
- (NSArray*) resultsOfApplyingSelector:(SEL)sel;
@end
@interface NSDictionary (HigherOrderOperations)
- (NSMutableDictionary*) mutableResultsOfApplyingSelector:(SEL)sel withObject:arg;
- (NSDictionary*) resultsOfApplyingSelector:(SEL)sel withObject:arg;
@end
#pragma mark NSFileManager Extensions
@interface NSFileManager (VTPGExtensions)
- (NSDate*) modificationDateOfItemAtURL:(NSURL*)fileURL;
@end
@interface NSDate (VTPGDateComparison)
- (BOOL) isBefore:(NSDate*)otherDate;
- (BOOL) isAfter:(NSDate*)otherDate;
@end