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