Swift - 把汉字转换为拼音,并且截取首字母做索引用

 

var transformContents = CFStringCreateMutableCopy(nil, 0, "咋啊的看到回复阿斯顿发货发哦iasdifas")

CFStringTransform(transformContents, nil, kCFStringTransformMandarinLatin, 0)

var traStr:String = transformContents as String

let index = advance(traStr.startIndex, 1)

traStr.uppercaseString.substringToIndex(index)

posted @ 2017-02-17 17:14  公羽寒  阅读(1741)  评论(0编辑  收藏  举报