CamelCase to underscores and back in Objective-C
问题 I'm looking for a simple, efficient way to convert strings in CamelCase to underscore notation (i.e., MyClassName -> my_class_name) and back again in Objective C. My current solution involves lots of rangeOfString , characterAtIndex , and replaceCharactersInRange operations on NSMutableStrings, and is just plain ugly as hell :) It seems that there must be a better solution, but I'm not sure what it is. I'd rather not import a regex library just for this one use case, though that is an option