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 ...
随机推荐
- java项目文件的路径问题
title: 项目下的路径问题 tags: grammar_cjkRuby: true --- 在javaee的项目中,存取文件,解析xml和properties文件,以及项目中的文件,都需要获取路径 ...
- shell 统计词频脚本
#!/bin/bash if [ $# -ne 1 ]; then echo "Usage:$0 filename"; exit -1 fi filename=$1 egrep - ...
- 网络工具 NetCat
http://netcat.sourceforge.net/ windows 版本 https://joncraton.org/blog/46/netcat-for-windows/ https:// ...
- 用idea工具对java打包:命令 mvn clear package,报错
用idea工具对java打包:命令 mvn clear package,报错 网上都是eclipse的,要么是project structure和setting的(当然这俩也要用) 我都试了,每一个能 ...
- caffe c++
http://blog.csdn.net/yao_zhuang/article/details/1853625
- stm32之入门知识
一.stm32最小系统 stm32最小系统组成如下(除了stm32芯片外): 1.电源模块,3.3V电源,需要用稳压器件,有时要用感容网络产生stm32所使用的模拟电源. 2.时钟模块,有源或者无源晶 ...
- Apress 出版社电子书
http://www.apress.com/ 国外收费电子书网站,电子书权威,比国内的还便宜
- Oracle 11gr2的完全卸载
Oracle 11gr2的完全卸载方式与前些版本有了改变,运行D:\app\Administrator\product\11.2.0\dbhome_1\deinstall的deinstall.bat批 ...
- HDU - 3664 Permutation Counting 排列规律dp
Permutation Counting Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the ...
- Java负数的位运算
/** * 求负数的位运算 *///1. -10 >> 2 = ?//2. -10的原码: 1000 0000 0000 0000 0000 0000 0000 1010 最高位代表符号位 ...