你的位置:首页 > 操作系统

[操作系统]iOS 汉字的拼音


#import <Foundation/Foundation.h>@interface NSString (Utils)/** * 汉字的拼音 * * @return 拼音 */- (NSString *)pinyin;@end#import "NSString+Utils.h"@implementation NSString (Utils)//汉字的拼音- (NSString *)pinyin{    NSMutableString *str = [self mutableCopy];  CFStringTransform(( CFMutableStringRef)str, NULL, kCFStringTransformMandarinLatin, NO);  CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformStripDiacritics, NO);    return [str stringByReplacingOccurrencesOfString:@" " withString:@""];}@end