标签:
//判断字符串是否是中文 if ([ChineseInclude isIncludeChineseInString:@“百度"]) //然后将中文转换成拼音 NSString *pybody = [PinYinForObjc chineseConvertToPinYin:@"百度"]; //同时将中文转换成拼音首字母 NSString *pyheader = [PinYinForObjc chineseConvertToPinYinHead:@“百度”];
.
同时将拼音和拼音首字母加入关联 for (MenuItemObject *objmenu in allmenus) { //检测是否是有中文 if ([ChineseInclude isIncludeChineseInString:objmenu.displayname]) { //转换为拼音,和拼音首字母 NSString *pybody = [PinYinForObjc chineseConvertToPinYin:objmenu.displayname]; NSString *pyheader = [PinYinForObjc chineseConvertToPinYinHead:objmenu.displayname]; //将其索引关联上本地搜索引擎 [[PermissiveResearchDatabase sharedDatabase] addRetainedObjet:objmenu forKey:pybody]; [[PermissiveResearchDatabase sharedDatabase] addRetainedObjet:objmenu forKey:pyheader]; } [[PermissiveResearchDatabase sharedDatabase] addRetainedObjet:objmenu forKey:objmenu.displayname]; }
iOS- 本地文本容错搜索引擎2-->如何实现英文(英文首字母,汉语拼音)对中文的搜索?
标签:
原文地址:http://www.cnblogs.com/qingche/p/5019683.html