将C++的标识符转成OC的标识符
3.将C++的标识符转成OC的标识符
C++的标识符和OC一样由数字字母下划线组成。打头的不是数字。当标识符超过一个单词,
C++採用全字母小写。单词间用下划线连接的书写规范,如:
bei_jing
OC採用除第一个单词外,其余单词首字母大写的书写规范。如:
beiJing //传入C++标识符,返回OC标识符 */
+ (NSString *)objcIdentifierFromCppIdentifier:(NSString *)idf
//{
// //首先获取第0个字母
// NSMutableString * str1 = [NSMutableString stringWithFormat:@"%c",[idf characterAtIndex:0]];
// // 从第一个字母往后遍历。遇到‘_’符号后,取出‘_’后的字符将小写转换为大写,让i+1。否则,直接拼接
// 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 (NSInteger i = 0; i < idf.length; i++) {
// unichar ch = [idf characterAtIndex:i];
// if (ch == '_') {
// unichar ch = [idf characterAtIndex:i+1];
// [str appendFormat:@"%c",ch-32];
// i++;
// }
// else
// {
// [str appendFormat:@"%c",ch];
// }
// }
// return str;
//}
{
NSMutableString * str = [ NSMutableString stringWithFormat:@"%c",[idf characterAtIndex:0]];
for(NSInteger i = 1;i < idf.length;i++)
{
unichar ch = [idf characterAtIndex:i];
if(ch == '_')
{
unichar ch = [idf characterAtIndex:i+1];
[str appendFormat:@"%c",ch-32];
i++;
}
else
{
[str appendFormat:@"%c",ch];
}
}
return str;
}
将C++的标识符转成OC的标识符的更多相关文章
- html5 请求的URL转成 OC可用属性字符串显示
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:helpUrlStr]]; NSString *string = [ ...
- iOS开发 将html 富文本文字 转换成oc 的富文本
- (NSMutableAttributedString *)mf_htmlAttribute:(NSString *)htmlString{ htmlString = [NSString strin ...
- oc字符串+数组+字典操作题目
1. 判断中间目录是否存在 (10分) 比如 传入字符串 @"/home/qianfeng/oc.txt" 和 @"qianfeng" 返回:YES 传入字符串 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- 面试时如何优雅的谈论OC
在面试中,我们经常会遇到一些原理性的问题,很常识但很难用通俗的语言解释清楚,这也是大部分业务级程序员经常失误的地方.虽然写了多年代码,但是核心思想不清,导致自己的后续发展受限,这是一个优秀的程序员和普 ...
- OC中的自动引用计数
目录: 1,自动引用计数的定义 2,强引用和弱引用 3,类比手动引用 4,循环引用 5,CoreFoundation 内容: 自动引用计数的定义: (Automatic Reference Count ...
- oc 字符串
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { ...
- OC字符串的一些常用的函数。
)//获取字符串长度 NSUInteger len= str.length; () //通过指定索引返回对应的字符 unichar ch =[str characterAtIndex:]; ()//通 ...
- OC语言-07-OC语言-Foundation框架
结构体 NSRange/CGRange 用来表示一个元素在另一个元素中的范围,NSRange等价于CGRange 包含两个属性: NSUInteger location:表示一个元素在另一个元素中的位 ...
随机推荐
- focus,focusin,blur,focusout区别
focus与focusin 1.共同点:当 <div> 元素或其任意子元素获得焦点时执行事件 2.区别:focus不支持冒泡,而focusin支持冒泡: blur与focusout 1.共 ...
- C指针复制字符串从一个数组到另一个数组
#include <stdio.h> void copyString (char *to, char *from) { while ( *from ) // from指针遇 ...
- metasploitable2更改root密码
metasploitable2这个系统众所周知,一个用户名和密码是msfadmin.但是这个账号权限不全,我们想要改root密码来登陆为所欲为.也没试过破解,咱们索性就改了吧. 就简单几行代码.. ...
- 条款34:区分接口继承和实现继承(Different between inheritance of interface and inheritance of implemenation)
NOTE: 1.接口继承和实现继承不同.在public继承之下,derived classes总是继承base class的接口. 2.pure virtual 函数只具体指定接口继承及缺省实现继承. ...
- vue ui组件muse-ui的使用
安装 npm install muse-ui typeface-roboto material-design-icons vuex axios --save Muse UI 是一套 Material ...
- Centos7 中Nginx的安装与配置
安装与配置 1.安装nginx yum intsall nginxsudo systemctl start nginx 启动服务sudo firewall-cmd --permanent --zone ...
- xtu summer individual 2 D - Colliders
Colliders Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Origi ...
- UITableView点击背景
系统自定义的点击背景有时间觉得效果不好想换个 - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelect ...
- php实现设计模式————单例模式
php实现设计模式————单例模式 什么是单例模式 为什么要使用单例模式 php中有哪些方式实现新建一个对象实例 如何阻止这种实例化实现理想的单例模式 代码实现 什么是单例模式 为什么要使用单例模式 ...
- java Web项目Service层通用接口和entityVo对象与entity对象转化问题的解决方案
Service层的接口中有一些比较常用方法,一次又一次的在新的Service层中被书写,所以懒惰的程序员又烦了,他们决定写个通用接口来解决这个问题. 有些项目中,实体类即承担接收表单数据的任务,又承担 ...