Created
July 27, 2014 20:12
-
-
Save chivalry/2d70fb38e0895bf049af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)camelCaseToTitleCase { | |
NSMutableString *string = [NSMutableString string]; | |
NSCharacterSet *upper = [NSCharacterSet uppercaseLetterCharacterSet]; | |
for (NSInteger index = 0; index < [self length]; index++) { | |
NSString *character = [self substringWithRange:NSMakeRange(index, 1)]; | |
if ([character rangeOfCharacterFromSet:upper].location != NSNotFound) { | |
[string appendString:@" "]; | |
} | |
[string appendString:character]; | |
} | |
return [string capitalizedString]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment