ios 根据字典自动生成属性
- (void)createPropertyCode
{
NSMutableString *codes = [NSMutableString string];
// 遍历字典
[self enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull value, BOOL * _Nonnull stop) {
NSString *code;
if ([value isKindOfClass:[NSString class]]) {
code = [NSString stringWithFormat:@"@property (nonatomic, copy) NSString *%@",key];
}else if ([value isKindOfClass:NSClassFromString(@"__NSCFBoolean")]){
code = [NSString stringWithFormat:@"@property (nonatomic, assion) BOOL %@",key];
}else if ([value isKindOfClass:NSClassFromString(@"__NSCFNumber")]){
code = [NSString stringWithFormat:@"@property (nonatomic, assion) NSInteger %@",key];
}else if ([value isKindOfClass:NSClassFromString(@"__NSArrayI")]){
code = [NSString stringWithFormat:@"@property (nonatomic, strong) NSArray *%@",key];
}else if ([value isKindOfClass:NSClassFromString(@"__NSCFDictionary")]){
code = [NSString stringWithFormat:@"@property (nonatomic, strong) NSDictionary *%@",key];
}
[codes appendFormat:@"\n%@\n",code];
}];
NSLog(@"codes = %@",codes);
}
ios 根据字典自动生成属性的更多相关文章
- iOS 创建模型时自动生成属性
转载 mark666(简书作者), 链接:http://www.jianshu.com/p/63ee533a7705 我们在创建模型的时候,常常要写一大堆恶心的@property(nonatomic, ...
- Visual Studio 2017 怎么将自动生成属性设置为旧版格式
工具:Visual Studio 2017 1.点击工具,进入选项 2.选项窗口左侧找到C#--代码样式,点击 3.找到表达式首选项中:使用属性的表达式主体.使用索引器的表达式主体和使用访问器的表达式 ...
- OC知识点(类方法,构造方法,组合模式,get,set方法,自动生成属性)
1.类方法的优势 不用创建对象,节省了空间,直接用类名调用类方法,类方法为外界提供一个方便的调用接口.(特点:类方法以加号开头,不能使用自身的成员变量,它的调用不依赖成员变量) 2.构造方法(初始化成 ...
- iOS 字典自动生成模型
在实际开发中,我们经常需要根据字典来建模型.每次都打那么一串代码,想想也是挺恶心的.可以自己给NSDictionary写一个分类,进行属性生成. NSDictionary+Property.h #im ...
- 第30月第3天 iOS图标icon自动生成和自定义尺寸
1. http://icon.wuruihong.com/ https://www.jianshu.com/p/684751c14735 2.status bar UIViewControllerBa ...
- python根据字典自动生成一组省和市名
字典如下: dict={ '河北省':['石家庄','唐山','秦皇岛','承德'], '山东省':['济南','青岛','临沂','淄博'], '湖南省':['长沙','衡阳','湘潭','邵阳', ...
- Object的属性property详细解释(自动生成成员变量)
类Class中的属性property: 在ios第一版中,我们为输出口同时声明了属性和底层实例变量,那时,属性是oc语言的一个新的机制,并且要求你必须声明与之对应的实例变量,例如: @interfac ...
- iOS - WWDC18 iOS 自动生成强密码和自动填充验证码/密码
本文将介绍WWDC18 Automatic Strong Passwords and Security Code Autofill和WWDC17 Introducing Password AutoFi ...
- 自动生成数据库字典(sql2008)
每次做项目的时候都要做数据字典,这种重复的工作实在很是痛苦,于是广找资料,终于完成了自动生成数据库字典的工作,废话少说,上代码. 存储过程: SET ANSI_NULLS ON GO SET QUOT ...
随机推荐
- Docker入门(七):部署app
这个<Docker入门系列>文档,是根据Docker官网(https://docs.docker.com)的帮助文档大致翻译而成.主要是作为个人学习记录.有错误的地方,Robin欢迎大家指 ...
- ng2中的ng-content用法
用途:1.ng-content用于在组件中嵌入内容 2.ng-content可以在组件中嵌入模板代码,方便定制可复用的组件 select属性支持css选择器,如"#id",&quo ...
- Entity Framework之领域驱动设计实践
http://www.cnblogs.com/daxnet/archive/2010/11/02/1867392.html
- Will you still need me?
ON FRIDAY, the National Bureau of Statistics announced that China's working-age population shrank la ...
- vs2013错误 1 Unable to find messages file 'cscui.dll'
最近使用VS编译的时候,提示错误 错误 1 Unable to find messages file 'cscui.dll' 搜索后,几乎只有1个结果,就是搜索cscui.dll 把正常大小的文件替 ...
- error: field has incomplete type
在头文件使用某一自定义的类的指针或引用时,只需要前置声明该类即可,然而如果该类中有静态成员时,必须包含该类的头文件,而不是使用前置声明.
- Consuming JSON Strings in SQL Server
https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/ Consuming JS ...
- HDU - 5878 2016青岛网络赛 I Count Two Three(打表+二分)
I Count Two Three 31.1% 1000ms 32768K I will show you the most popular board game in the Shanghai ...
- Apache Shiro知识点总览
名词解释 权限认证 授权 ini文件配置 jsp标签授权 Shiro会话机制 自定义Realm 加密.解密 特性 与spring整合 名词解释 Subject:认证主体 Reaml:认证来源[jdbc ...
- C#代码生成器附百度云盘源码地址
今晚闲着没事,写了个代码生成器,在这里只做个抛砖引玉,后面可以继续扩展功能,下方附百度云盘源码地址. 使用数据库:sqlserver 编译器:vs2015 废话不多说,上界面: 程序主界面: 数据库: ...