From 786fb58eecb2d9740c5c1b0dcd4beb6f4a868aa6 Mon Sep 17 00:00:00 2001 From: Anviking Date: Thu, 1 Aug 2013 23:38:54 +0200 Subject: [PATCH] General cleanup --- Chromatism/Chromatism/Helpers.m | 109 ------------------------- Chromatism/Chromatism/JLTokenPattern.m | 8 +- 2 files changed, 4 insertions(+), 113 deletions(-) diff --git a/Chromatism/Chromatism/Helpers.m b/Chromatism/Chromatism/Helpers.m index b0152c3..fabfc71 100644 --- a/Chromatism/Chromatism/Helpers.m +++ b/Chromatism/Chromatism/Helpers.m @@ -8,84 +8,6 @@ #import "Helpers.h" -@implementation NSString (Helper) - -- (BOOL)string:(NSString *)longString containsString:(NSString *)shortString -{ - return ([longString rangeOfString:shortString].length != NSNotFound); -} - -- (NSMutableArray *)allOccurrencesOfString:(NSString *)searchString { - - NSMutableArray *array = [NSMutableArray array]; - - BOOL keepGoing = TRUE; - NSRange searchRange = NSMakeRange(0, self.length); - while (keepGoing) { - NSRange range = [self rangeOfString:searchString options:NSCaseInsensitiveSearch range:searchRange]; - if (range.location != NSNotFound) { - int pos = range.location + searchString.length; - [array addObject:[NSValue valueWithRange:range]]; - - searchRange = NSMakeRange(pos, [self length] - pos); - - } else { - keepGoing = NO; - } - } - - return array; -} - -@end - -@implementation NSArray (Helper) - -- (NSArray *)uniqueArray; -{ - NSMutableSet* existingNames = [NSMutableSet set]; - NSMutableArray* filteredArray = [NSMutableArray array]; - for (id object in self) { - if (![existingNames containsObject:[object name]]) { - [existingNames addObject:[object name]]; - [filteredArray addObject:object]; - } - } - return [NSArray arrayWithArray:filteredArray]; -} -@end - -@implementation NSMutableArray (Helper) - -- (NSMutableArray *)uniqueArray; -{ - NSMutableSet* existingNames = [NSMutableSet set]; - NSMutableArray* filteredArray = [NSMutableArray array]; - for (id object in self) { - if (![existingNames containsObject:object]) { - [existingNames addObject:object]; - [filteredArray addObject:object]; - } - } - return filteredArray; -} - -@end - -@implementation NSValue (Helper) - -- (NSComparisonResult)compareTo:(NSValue *)range { - if (self.rangeValue.location < range.rangeValue.location) { - return NSOrderedAscending; - } else if (self.rangeValue.location == range.rangeValue.location) { - return NSOrderedSame; - } else { - return NSOrderedDescending; - } -} - -@end - @implementation UIColor (CreateMethods) + (UIColor*)colorWith8BitRed:(NSInteger)red green:(NSInteger)green blue:(NSInteger)blue alpha:(CGFloat)alpha { @@ -117,37 +39,6 @@ + (UIColor*)colorWithHex:(NSString*)hex alpha:(CGFloat)alpha { @end -@implementation NSAttributedString (help) - -- (NSString *)description -{ - return self.string; -} - -@end - -@implementation NSMutableAttributedString (help) - -- (NSString *)description -{ - return self.string; -} - -@end - -@implementation NSDate (Helper) - -- (NSString *)iso8601String -{ - static NSDateFormatter* dateFormatter; - if (!dateFormatter) - { - dateFormatter = [[NSDateFormatter alloc] init]; - [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZ"]; - } - return [dateFormatter stringFromDate:self]; -} -@end @implementation NSIndexSet (GSIndexSetAdditions) - (NSMutableIndexSet *)intersectionWithSet:(NSIndexSet *)otherSet diff --git a/Chromatism/Chromatism/JLTokenPattern.m b/Chromatism/Chromatism/JLTokenPattern.m index dc5abc8..e2094b6 100644 --- a/Chromatism/Chromatism/JLTokenPattern.m +++ b/Chromatism/Chromatism/JLTokenPattern.m @@ -9,9 +9,11 @@ #import "JLTokenPattern.h" @interface JLScope () -@property (nonatomic, readwrite, strong) NSString *string; - (void)iterateSubscopes; - (BOOL)shouldPerform; + +@property (nonatomic, readwrite, strong) NSString *string; + @end @implementation JLTokenPattern @@ -40,14 +42,12 @@ - (id)init - (void)setExpression:(NSRegularExpression *)expression { _expression = expression; - - self.pattern = expression.pattern; + _pattern = expression.pattern; } - (void)setPattern:(NSString *)pattern { _pattern = pattern; - _expression = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionAnchorsMatchLines error:nil]; }