{"id":131,"date":"2014-11-28T16:57:21","date_gmt":"2014-11-28T08:57:21","guid":{"rendered":"http:\/\/www.olinone.com\/?p=131"},"modified":"2015-12-07T18:54:35","modified_gmt":"2015-12-07T10:54:35","slug":"ios%e5%bc%80%e5%8f%91%e4%b8%ad%e5%a6%82%e4%bd%95%e6%9b%b4%e5%bf%ab%e7%9a%84%e5%ae%9e%e7%8e%b0%e6%b1%89%e5%ad%97%e8%bd%ac%e6%8b%bc%e9%9f%b3","status":"publish","type":"post","link":"http:\/\/www.olinone.com\/?p=131","title":{"rendered":"iOS\u5f00\u53d1\u4e2d\u5982\u4f55\u66f4\u5feb\u7684\u5b9e\u73b0\u6c49\u5b57\u8f6c\u62fc\u97f3"},"content":{"rendered":"<p>\u6700\u8fd1\u5728\u505a\u5b57\u7b26\u4e32\u8f6c\u62fc\u97f3\u7684\u901f\u5ea6\u4f18\u5316\uff0c\u73b0\u5206\u4eab\u7ed9\u5927\u5bb6\uff0c\u5404\u4f4d\u670b\u53cb\u6709\u4ec0\u4e48\u60f3\u6cd5\u53ef\u4ee5\u7ed9\u6211\u7559\u8a00\uff0c\u8c22\u8c22\uff01<\/p>\n<p>&nbsp;<\/p>\n<h3>\u7b2c\u4e00\u9636\u6bb5\uff1agit\u5f00\u6e90\u5de5\u5177\uff1a<a href=\"https:\/\/github.com\/kimziv\/PinYin4Objc\">PinYin4Objc<\/a><\/h3>\n<h3>\u7b2c\u4e8c\u9636\u6bb5\uff1a\u7f51\u53cb\u63a8\u8350\u65b9\u6cd5<\/h3>\n<pre class=\"lang:objc highlight:0 decode:true\">- (NSString *)transformToPinyin {\r\n    NSMutableString *mutableString = [NSMutableString stringWithString:self];\r\n    CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, false);\r\n    CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformStripDiacritics, false);\r\n    return mutableString;\r\n}<\/pre>\n<h3>\u7b2c\u4e09\u9636\u6bb5\uff1a \u6b63\u5219\u8868\u8fbe\u5f0f\u4f18\u5148\u8fc7\u6ee4\u82f1\u6587\u6570\u5b57\u7279\u6b8a\u5b57\u7b26\u7b49<\/h3>\n<pre class=\"lang:objc highlight:0 decode:true\">- (NSString *)transformToPinyin {\r\n    NSMutableString *mutableString = [NSMutableString stringWithString:self];\r\n    BOOL isNeedTransform = ![self isAllEngNumAndSpecialSign];\r\n    if (isNeedTransform) {\r\n        CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, false);\r\n        CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformStripDiacritics, false);\r\n    }\r\n    return mutableString;\r\n}\r\n\r\n- (BOOL)isAllEngNumAndSpecialSign {\r\n    NSString *regularString = @\"^[A-Za-z0-9\\\\p{Z}\\\\p{P}]+$\";\r\n    NSPredicate *predicate = [NSPredicate predicateWithFormat:@\"SELF MATCHES %@\", regularString];\r\n    return [predicate evaluateWithObject:self];\r\n}<\/pre>\n<h3>\u7b2c\u56db\u9636\u6bb5\uff1a\u53c2\u8003<a href=\"http:\/\/nshipster.com\/cfstringtransform\/\">http:\/\/nshipster.com\/cfstringtransform\/<\/a><\/h3>\n<pre class=\"lang:objc highlight:0 decode:true\">- (NSString *)transformToPinyin {\r\n    NSMutableString *mutableString = [NSMutableString stringWithString:self];\r\n    BOOL isNeedTransform = ![self isAllEngNumAndSpecialSign];\r\n    if (isNeedTransform) {\r\n        CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, false);\r\n        CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformStripCombiningMarks, false);\r\n    }\r\n    return mutableString;\r\n}\r\n\r\n- (BOOL)isAllEngNumAndSpecialSign {\r\n    NSString *regularString = @\"^[A-Za-z0-9\\\\p{Z}\\\\p{P}]+$\";\r\n    NSPredicate *predicate = [NSPredicate predicateWithFormat:@\"SELF MATCHES %@\", regularString];\r\n    return [predicate evaluateWithObject:self];\r\n}<\/pre>\n<h3>\u7b2c\u4e94\u9636\u6bb5\uff1a\u7ec8\u6781\u4f18\u5316\u7248<\/h3>\n<pre class=\"lang:objc highlight:0 decode:true\">- (NSString *)transformToPinyin {\r\n    NSMutableString *mutableString = [NSMutableString stringWithString:self];\r\n    CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, false);\r\n    mutableString = (NSMutableString *)[mutableString stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:[NSLocale currentLocale]];\r\n    return [mutableString stringByReplacingOccurrencesOfString:@\"'\" withString:@\"\"];\r\n}<\/pre>\n<p>Demo\u79fb\u6b65<a href=\"https:\/\/github.com\/panghaijiao\/PHJTransformPinyinDemo\">https:\/\/github.com\/panghaijiao\/PHJTransformPinyinDemo<\/a>\uff0c\u611f\u8c22\u4f60\u7684\u6765\u8bbf\uff01<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5728\u505a\u5b57\u7b26\u4e32\u8f6c\u62fc\u97f3\u7684\u901f\u5ea6\u4f18\u5316\uff0c\u73b0\u5206\u4eab\u7ed9\u5927\u5bb6\uff0c\u5404\u4f4d\u670b\u53cb\u6709\u4ec0\u4e48\u60f3\u6cd5\u53ef\u4ee5\u7ed9\u6211\u7559\u8a00\uff0c\u8c22\u8c22\uff01 &nbsp; \u7b2c\u4e00\u9636\u6bb5\uff1a\u2026 <span class=\"read-more\"><a href=\"http:\/\/www.olinone.com\/?p=131\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,6],"tags":[],"_links":{"self":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/131"}],"collection":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":16,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":402,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions\/402"}],"wp:attachment":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}