- (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 根据字典自动生成属性的更多相关文章

  1. iOS 创建模型时自动生成属性

    转载 mark666(简书作者), 链接:http://www.jianshu.com/p/63ee533a7705 我们在创建模型的时候,常常要写一大堆恶心的@property(nonatomic, ...

  2. Visual Studio 2017 怎么将自动生成属性设置为旧版格式

    工具:Visual Studio 2017 1.点击工具,进入选项 2.选项窗口左侧找到C#--代码样式,点击 3.找到表达式首选项中:使用属性的表达式主体.使用索引器的表达式主体和使用访问器的表达式 ...

  3. OC知识点(类方法,构造方法,组合模式,get,set方法,自动生成属性)

    1.类方法的优势 不用创建对象,节省了空间,直接用类名调用类方法,类方法为外界提供一个方便的调用接口.(特点:类方法以加号开头,不能使用自身的成员变量,它的调用不依赖成员变量) 2.构造方法(初始化成 ...

  4. iOS 字典自动生成模型

    在实际开发中,我们经常需要根据字典来建模型.每次都打那么一串代码,想想也是挺恶心的.可以自己给NSDictionary写一个分类,进行属性生成. NSDictionary+Property.h #im ...

  5. 第30月第3天 iOS图标icon自动生成和自定义尺寸

    1. http://icon.wuruihong.com/ https://www.jianshu.com/p/684751c14735 2.status bar UIViewControllerBa ...

  6. python根据字典自动生成一组省和市名

    字典如下: dict={ '河北省':['石家庄','唐山','秦皇岛','承德'], '山东省':['济南','青岛','临沂','淄博'], '湖南省':['长沙','衡阳','湘潭','邵阳', ...

  7. Object的属性property详细解释(自动生成成员变量)

    类Class中的属性property: 在ios第一版中,我们为输出口同时声明了属性和底层实例变量,那时,属性是oc语言的一个新的机制,并且要求你必须声明与之对应的实例变量,例如: @interfac ...

  8. iOS - WWDC18 iOS 自动生成强密码和自动填充验证码/密码

    本文将介绍WWDC18 Automatic Strong Passwords and Security Code Autofill和WWDC17 Introducing Password AutoFi ...

  9. 自动生成数据库字典(sql2008)

    每次做项目的时候都要做数据字典,这种重复的工作实在很是痛苦,于是广找资料,终于完成了自动生成数据库字典的工作,废话少说,上代码. 存储过程: SET ANSI_NULLS ON GO SET QUOT ...

随机推荐

  1. Java Security(JCE基本概念)

    Java Security网络环境中的安全隐患计算机安全OSI参考结构模型五类安全服务八类安全机制网络环境中的安全隐患1. 存储问题: 移动存储设备存储数据没有加密存在的安全隐患 2. 通信问题: 用 ...

  2. Algorithms & Data structures in C++& GO ( Lock Free Queue)

    https://github.com/xtaci/algorithms //已实现 ( Implemented ): Array shuffle https://github.com/xtaci/al ...

  3. ClientSocket.h ClientSocket.cpp

    ClientSocket.h #pragma once // CClientSocket 命令目标 #include "ClientProDlg.h" #include " ...

  4. 细说 CSS margin

    作者:https://coding.net/u/zhengkenghong原文:https://blog.coding.net/blog/css-margin 细说 CSS margin 本文着重描述 ...

  5. 使用 Addr2line 将函数地址解析为函数名

    用 Addr2line 将函数地址解析为函数名 原文链接:http://www.ibm.com/developerworks/cn/linux/l-graphvis/ Addr2line 工具(它是标 ...

  6. 7.12实习培训日志 Linux Docker

    Linux 管理 RHEL7 的用户和组 用户的属性修改 chage -l [username] #查看用户信息 usermod --expiredate=YYYY-MM-DD [username] ...

  7. HERO3+ Black Edition 视角 (FOV) 信息

    HERO3+ Black Edition 视角 (FOV) 信息 问题  HERO3+ Black Edition 视角 (FOV) 信息是什么? 它在哪适用? HERO3+ Black 作答 所有视 ...

  8. OrderBy和OrderByDescending排序

    昨天有练习对数字阵列进行排序,<C#阵列Array排序>https://www.cnblogs.com/insus/p/10825174.html 其实一切都弄得很复杂,array已经有2 ...

  9. linux文件重命名

    rename 命令用字符串替换的方式批量改变文件名. 语法 rename(参数) 参数 原字符串:将文件名需要替换的字符串: 目标字符串:将文件名中含有的原字符替换成目标字符串: 文件:指定要改变文件 ...

  10. Android权限之三共享UID和签名

    http://blog.csdn.net/a345017062/article/details/6236263 共享UID 安装在设备中的每一个Android包文件(.apk)都会被分配到一个属于自己 ...