Skip to content

Commit

Permalink
General cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Aug 1, 2013
1 parent 01121c9 commit 786fb58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 113 deletions.
109 changes: 0 additions & 109 deletions Chromatism/Chromatism/Helpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Chromatism/Chromatism/JLTokenPattern.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
}

Expand Down

0 comments on commit 786fb58

Please sign in to comment.