NSMutableString *str = [NSMutableString stringWithString:aString];
1.獲取漢字的拼音(帶聲調(diào))
CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformMandarinLatin,NO);
2.獲取漢字的拼音(不帶聲調(diào))
CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformStripDiacritics,NO);
3.轉(zhuǎn)化為大寫拼音
NSString *pinYin = [str capitalizedString];
4.獲取到首字母并且轉(zhuǎn)換為大寫
- (NSString *)firstCharactor:(NSString *)aString
{
//轉(zhuǎn)成了可變字符串
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];
}