NSMutableString *pinyin = [_name mutableCopy];
//转换成拼音
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
//去掉音调
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripDiacritics, NO);
NSLog(@"pinyin= %@",pinyin);
// 截取首字母
NSString * first = [pinyin substringToIndex:1];
NSLog(@"%@", first);
时间: 2024-11-05 18:54:45