diff options
| author | mo khan <mo@mokhan.ca> | 2013-07-14 19:25:33 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-07-14 19:25:33 -0600 |
| commit | 3ee7f1cc9d43bc44803b91b13838dee1f6d7bad8 (patch) | |
| tree | 3aa21f99544ef8d7e10baa0733821e03f25d9574 /cakeside-ios/utility | |
| parent | e20daadad8076309b21314379dc1fed048ca6903 (diff) | |
remove dead code
Diffstat (limited to 'cakeside-ios/utility')
| -rw-r--r-- | cakeside-ios/utility/NSDictionary+Additions.h | 13 | ||||
| -rw-r--r-- | cakeside-ios/utility/NSDictionary+Additions.m | 26 | ||||
| -rw-r--r-- | cakeside-ios/utility/NSString+Additions.h | 33 | ||||
| -rw-r--r-- | cakeside-ios/utility/NSString+Additions.m | 159 | ||||
| -rw-r--r-- | cakeside-ios/utility/NSString+Extensions.h | 5 | ||||
| -rw-r--r-- | cakeside-ios/utility/NSString+Extensions.m | 14 |
6 files changed, 19 insertions, 231 deletions
diff --git a/cakeside-ios/utility/NSDictionary+Additions.h b/cakeside-ios/utility/NSDictionary+Additions.h deleted file mode 100644 index 456359b..0000000 --- a/cakeside-ios/utility/NSDictionary+Additions.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// NSDictionary+NSDictionary_Additions.h -// fastcab-driver -// -// Created by Rick Cotter on 12-03-20. -// Copyright (c) 2012 Assn. All rights reserved. -// - -#import <Foundation/Foundation.h> - -@interface NSDictionary (Additions) --(id) objectForKey:(NSString *)key defaultValue:(id)defaultValue; -@end diff --git a/cakeside-ios/utility/NSDictionary+Additions.m b/cakeside-ios/utility/NSDictionary+Additions.m deleted file mode 100644 index 01f3569..0000000 --- a/cakeside-ios/utility/NSDictionary+Additions.m +++ /dev/null @@ -1,26 +0,0 @@ -// -// NSDictionary+NSDictionary_Additions.m -// fastcab-driver -// -// Created by Rick Cotter on 12-03-20. -// Copyright (c) 2012 Assn. All rights reserved. -// - -#import "NSDictionary+Additions.h" - -@implementation NSDictionary (Additions) - --(id) objectForKey:(NSString *)key defaultValue:(id)defaultValue { - id value = [self objectForKey:key]; - if (!value) { - return defaultValue; - } - - if (value == [NSNull null]) { - return defaultValue; - } - - return value; -} - -@end diff --git a/cakeside-ios/utility/NSString+Additions.h b/cakeside-ios/utility/NSString+Additions.h deleted file mode 100644 index a7f8a75..0000000 --- a/cakeside-ios/utility/NSString+Additions.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// NSString+Additions.h -// Cardinal -// -// Created by Cory Smith on 10-03-28. -// Copyright 2010 Assn. All rights reserved. -// - -@interface NSString (md5) - -+ (NSString *) md5:(NSString *)str; - -@end - -@interface NSString (Assn) -- (NSString *)trim; -- (BOOL)isEmpty; -- (BOOL)startsWith:(NSString *)starting; -- (BOOL)endsWith:(NSString *)ending; -- (BOOL)contains:(NSString *)text; -- (NSString *)urlEncode; -- (NSString *)replace:(NSString *)find with:(NSString *)replacement; -- (NSString *)replaceAll:(NSArray *)keys with:(NSArray *)values; - -// Replace newlines with <br /> tags. -- (NSString *)stringWithNewLinesAsBRs; - -- (NSString *)sanitizeForHTMLOutput; - -+ (NSString *)generateUUID; - -@end - diff --git a/cakeside-ios/utility/NSString+Additions.m b/cakeside-ios/utility/NSString+Additions.m deleted file mode 100644 index 57c782c..0000000 --- a/cakeside-ios/utility/NSString+Additions.m +++ /dev/null @@ -1,159 +0,0 @@ -// -// NSString+Additions.m -// Cardinal -// -// Created by Cory Smith on 10-03-28. -// Copyright 2010 Assn. All rights reserved. -// - -#import "NSString+Additions.h" - - -#import <CommonCrypto/CommonDigest.h> - -@implementation NSString (md5) - -+ (NSString *) md5:(NSString *)str { - const char *cStr = [str UTF8String]; - unsigned char result[16]; - CC_MD5( cStr, strlen(cStr), result ); - return [NSString stringWithFormat: - @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", - result[0], result[1], result[2], result[3], - result[4], result[5], result[6], result[7], - result[8], result[9], result[10], result[11], - result[12], result[13], result[14], result[15] - ]; -} - -@end - -@implementation NSString (Assn) - -- (NSString *)trim { - return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; -} - -- (BOOL)isEmpty { - return [[self trim] isEqualToString:@""]; -} - -- (BOOL)endsWith:(NSString *)ending { - - int indexToCheck = [self length] - [ending length]; - - if(indexToCheck >= 0) - return [[self substringFromIndex:indexToCheck] isEqualToString:ending]; - - return NO; -} - -- (BOOL)startsWith:(NSString *)starting { - if([starting isEmpty] || [starting length] > self.length) - return NO; - - return [[self substringToIndex:[starting length]] isEqualToString:starting]; -} - -- (NSString *)replace:(NSString *)find with:(NSString *)replacement { - return [self stringByReplacingOccurrencesOfString:find withString:replacement]; -} - - -- (NSString *)replaceAll:(NSArray *)keys with:(NSArray *)values { - - NSMutableString *s = [NSMutableString stringWithString:self]; - - for (int i = 0; i < keys.count; i++) { - [s replaceOccurrencesOfString:[keys objectAtIndex:i] - withString:[values objectAtIndex:i] - options:NSLiteralSearch - range:NSMakeRange(0, [s length])]; - } - - return s; -} - - -- (BOOL)contains:(NSString *)text { - NSRange range = [[self lowercaseString] rangeOfString:[text lowercaseString]]; - return range.location != NSNotFound; -} - -- (NSString *)urlEncode -{ - NSString *result = (__bridge NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)self, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8); - return result; -} - -- (NSString *)stringWithNewLinesAsBRs { - - // Strange New lines: - // Next Line, U+0085 - // Form Feed, U+000C - // Line Separator, U+2028 - // Paragraph Separator, U+2029 - - // Scanner - NSScanner *scanner = [[NSScanner alloc] initWithString:self]; - [scanner setCharactersToBeSkipped:nil]; - NSMutableString *result = [[NSMutableString alloc] init]; - NSString *temp; - NSCharacterSet *newLineCharacters = [NSCharacterSet characterSetWithCharactersInString: - [NSString stringWithFormat:@"\n\r"]]; - // Scan - do { - - // Get non new line characters - temp = nil; - [scanner scanUpToCharactersFromSet:newLineCharacters intoString:&temp]; - if (temp) [result appendString:temp]; - temp = nil; - - // Add <br /> s - if ([scanner scanString:@"\r\n" intoString:nil]) { - - // Combine \r\n into just 1 <br /> - [result appendString:@"<br />"]; - - } else if ([scanner scanCharactersFromSet:newLineCharacters intoString:&temp]) { - - // Scan other new line characters and add <br /> s - if (temp) { - for (NSUInteger i = 0; i < temp.length; i++) { - [result appendString:@"<br />"]; - } - } - - } - - } while (![scanner isAtEnd]); - - // Cleanup & return - NSString *retString = [NSString stringWithString:result]; - - // Return - return retString; - -} - - -- (NSString *)sanitizeForHTMLOutput -{ - NSString *result = self; - if (!result) { result = @""; } - result = [result trim]; - result = [result stringWithNewLinesAsBRs]; - return result; -} - -+ (NSString *)generateUUID -{ - CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault); - NSString * uuidString = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, newUniqueId); - CFRelease(newUniqueId); - - return uuidString; -} - -@end diff --git a/cakeside-ios/utility/NSString+Extensions.h b/cakeside-ios/utility/NSString+Extensions.h new file mode 100644 index 0000000..ad4308c --- /dev/null +++ b/cakeside-ios/utility/NSString+Extensions.h @@ -0,0 +1,5 @@ +@interface NSString (Extensions) +- (NSString *)trim; +- (BOOL)isEmpty; +@end + diff --git a/cakeside-ios/utility/NSString+Extensions.m b/cakeside-ios/utility/NSString+Extensions.m new file mode 100644 index 0000000..291d4ca --- /dev/null +++ b/cakeside-ios/utility/NSString+Extensions.m @@ -0,0 +1,14 @@ +#import "NSString+Extensions.h" +#import <CommonCrypto/CommonDigest.h> + +@implementation NSString (Extensions) + +- (NSString *)trim { + return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; +} + +- (BOOL)isEmpty { + return [[self trim] isEqualToString:@""]; +} + +@end |
