例如:textName -> text_name;
- (NSString *)snakeStyleStringFromHumpStyleString:(NSString *)originString {
NSArray *separatedArray = [originString componentsSeparatedByCharactersInSet:[NSCharacterSet uppercaseLetterCharacterSet]];
NSMutableString *processedString = [[NSMutableString alloc]init];
NSInteger loc = 0;
for (NSInteger i = 0; i < separatedArray.count - 1; i ++) {
NSString *item = [separatedArray objectAtIndex:i];
[processedString appendString:item];
NSString *upperCaseString = [originString substringWithRange:NSMakeRange(item.length + loc, 1)];
[processedString appendFormat:@"_%@",upperCaseString.lowercaseString];
loc += item.length;
loc += 1;
}
if (separatedArray.count) {
[processedString appendString:separatedArray.lastObject];
}
return processedString;
}