苹果自带拼音转换方法

 1 - (NSString *)getPinYinFrom:(NSString *)chinese
 2 {
 3     CFMutableStringRef string = CFStringCreateMutableCopy(NULL, 0, (__bridge CFMutableStringRef)[NSMutableString stringWithString:chinese]);
 4     CFStringTransform(string, NULL, kCFStringTransformMandarinLatin, NO);
 5     CFStringTransform(string, NULL, kCFStringTransformStripDiacritics, NO);
 6     
 7     NSMutableString *aNSString = (__bridge NSMutableString *)string;
 8     NSString *finalString = [aNSString stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%c", 32] withString:@""];
 9     
10     NSLog(@"%@", finalString);
11     return finalString;
12 }

以上由群内人人网的老王提供,我先 mark

posted @ 2013-11-22 18:18  yingkong1987  阅读(1148)  评论(0编辑  收藏  举报