//汉字转拼音之后,截取首字母,并大写 -(NSString *)transformCharacter:(NSString*)sourceStr { //先将原字符串转换为可变字符串 NSMutableString *ms = [NSMutableString stringWithString:sourceStr]; if (ms.length) { //将汉字转换为拼音 CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformToLatin, NO); //将拼音的声调去掉 CFStringTransform((__bridge CFMutableStringRef)ms, 0,kCFStringTransformStripDiacritics,NO); //将字符串所有字母大写 NSString *upStr = [ms uppercaseString]; //截取首字母 NSString *firstStr = [upStr substringToIndex:1]; return firstStr; } return @"#"; }