runtime 创建数据模型
来源:互联网 发布:js从入门到精通 编辑:程序博客网 时间:2024/06/06 10:52
objc_property_t * class_copyPropertyList(Class cls, unsigned int *outCount);//苹果文档获取类所有属性的接口
Class cls //要获取属性的类
unsigned int *outCount //一个指向该属性数组的一个计数指针
objc_property_t* //返回一个属性指针数组
具体实现
#import "Model.h"
#import <objc/message.h>
@implementation Model
+(instancetype)getDic:(NSDictionary*)dic{
Model * model = [[Model alloc]init];
unsigned int count = 0;
objc_property_t * ps = class_copyPropertyList([self class], &count);
for (int i = 0; i<count; i++) {
objc_property_t p = ps[i];
id obj = [dic objectForKey:[NSString stringWithFormat:@"%s",property_getName(p)]];
if (obj) {
[mode setValue:obj forKey:[NSString stringWithFormat:@"%s",property_getName(p)]];
}
}
return model;
}
@end
阅读全文
0 0
- runtime 创建数据模型
- RunTime应用--数据模型转换
- 数据模型创建及数据库连接
- runtime实现数据模型,自动绑定数据
- YII2 数据库配置&&创建数据模型
- android runtime 创建流程
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 数据模型
- 规范接口
- eclipse如何消除error pages的错误
- 动态规划---砝码称重问题
- NOIP普及组2009年 细胞分裂 题解
- 移动端车牌识别步骤概括为:车牌定位、车牌提取、字符识别
- runtime 创建数据模型
- flot
- String类的设计笔记----C++学习之路
- 51nod 1824(算法马拉松30)
- 在学习PHP过程中收集的网站
- 从零开始实现朴素贝叶斯分类算法(连续特征情形)
- Python--urllib3库详解1
- 集训 sum
- Spring(一)spring的原理