NSMutableString *str = [NSMutableString stringWithString:aString];
1.获取汉字的拼音(带声调)
CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformMandarinLatin,NO);
2.获取汉字的拼音(不带声调)
CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformStripDiacritics,NO);
3.转化为大写拼音
NSString *pinYin = [str capitalizedString];
4.获取到首字母并且转换为大写
- (NSString *)firstCharactor:(NSString *)aString
{
//转成了可变字符串
NSMutableString *str = [NSMutableString stringWithString:aString];CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformMandarinLatin,NO);CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformStripDiacritics,NO);
NSString *pinYin = [str capitalizedString];
//获取并返回首字母
return [pinYin substringToIndex:1];
}