Convert C + + identifiers to OC identifiers

Source: Internet
Author: User

3. Convert C + + identifiers to OC identifiers the identifiers of C + + are made up of alphanumeric underscores, not numbers. When the identifier is more than one word, C + + uses the full letter lowercase, the word between the words underlined by the writing specification, such as: Bei_jing OC In addition to the first word, the rest of the first letter of the writing specification, such as: Beijing//Incoming C + + identifier, return OC identifier */+ ( NSString *) Objcidentifierfromcppidentifier: (NSString *) idf//{////First get NO. 0 letter//nsmutablestring * str1 = [nsmutablestr  ing stringwithformat:@ "%c", [IDF characteratindex:0]];////from the first letter backwards, after encountering the ' _ ' symbol, remove the ' _ ' after the characters will be lowercase to uppercase, let i+1; otherwise, direct stitching//For (Nsinteger i = 1; i < idf.length; i++) {//Unichar ch = [IDF characteratindex:i];//if (ch = = ' _ ') {//ch = [IDF characteratindex:i+1];/ /[str1 appendformat:@ "%c", ch-32];//i++;//} else {//[str1 appendformat:@ "%c", CH ];//}//}//return str1;//}//{//nsmutablestring * str = [[Nsmutablestring alloc]init];//for (nsinteg Er i = 0; i < idf.length; i++) {//Unichar ch = [IDF characteratindex:i];//if (ch = = ' _ ') {//Unichar ch = [IDF Charactera tindex:i+1];//[Str appendformat:@ "%c", ch-32];//i++;//}//else//{//[str appendformat:@ "%c", ch];// }//}//return str;//}{nsmutablestring * str = [nsmutablestring stringwithformat:@ "%c", [IDF Characterat                      INDEX:0]]; for (Nsinteger i = 1;i < idf.length;i++) {Unichar ch = [IDF characteratin                          DEX:I];                              if (ch = = ' _ ') {Unichar ch = [IDF characteratindex:i+1];                              [Str appendformat:@ "%c", ch-32];                          i++;                          } else {[str appendformat:@ '%c ', CH]; }} return str;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Convert C + + identifiers to OC identifiers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.