Created
May 10, 2013 07:35
-
-
Save alexruperez/5552958 to your computer and use it in GitHub Desktop.
How to convert a NSString from snake_case to Title Case in Objective-C
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+SnakeCaseToTitleCase.h | |
// | |
// Copyright (c) 2013 alexruperez. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSString (SnakeCaseToTitleCase) | |
- (NSString*)snakeCaseToTitleCase; | |
@end |
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+SnakeCaseToTitleCase.m | |
// | |
// Copyright (c) 2013 alexruperez. | |
// | |
#import "NSString+SnakeCaseToTitleCase.h" | |
@implementation NSString (SnakeCaseToTitleCase) | |
- (NSString*)snakeCaseToTitleCase | |
{ | |
return [[self stringByReplacingOccurrencesOfString:@"_" withString:@" "] capitalizedString]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment