Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to convert a NSString from snake_case to Title Case in Objective-C
//
// NSString+SnakeCaseToTitleCase.h
//
// Copyright (c) 2013 alexruperez.
//
#import <Foundation/Foundation.h>
@interface NSString (SnakeCaseToTitleCase)
- (NSString*)snakeCaseToTitleCase;
@end
//
// 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
You can’t perform that action at this time.