自动生成属性

news/2024/7/19 10:19:37 标签: 爬虫

// 自动生成属性代码

- (void)createPropetyCode
{

    //模型中属性根据字典的key

    //有多少个key,生成多少个属性
    NSMutableString*codes = [NSMutableStringstring];

    //遍历字典
    [self enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull
value, BOOL * _Nonnull
stop) {

  NSString *code =nil;
 
  NSLog(@"%@",[value class]);

  if ([value isKindOfClass:[NSString class]])
{
          code = [NSString stringWithFormat:@"@property (nonatomic, strong) NSString *%@;",key];

  } else if([value isKindOfClass:NSClassFromString(@"__NSCFBoolean")]) 
{

       code = [NSString stringWithFormat:@"@property (nonatomic, assign) BOOL %@;",key];
  } else if([value isKindOfClass:[NSNumber class]])
{

       code = [NSString stringWithFormat:@"@property (nonatomic, assign) NSInteger %@;",key];
  } else if([value isKindOfClass:[NSArray class]])
{

        code = [NSString stringWithFormat:@"@property (nonatomic, strong) NSArray *%@;",key];

     
  } else if([value isKindOfClass:[NSDictionary class]])
{
        code = [NSString stringWithFormat:@"@property (nonatomic, strong) NSDictionary
*%@;",key];
  }

      // 拼接字符串

     
  [codes appendFormat:@"\n%@\n",code];

 

    }];

   NSLog(@"%@",codes);

}
复制代码

http://www.niftyadmin.cn/n/1380734.html

相关文章

PHP+Jquery+Ajax 实现动态生成GUID、加载GUID

GUID: 全局唯一标识符(GUID,Globally Unique Identifier)是一种由算法生成的二进制长度为128位的数字标识符。GUID主要用于在拥有多个节点、多台计算机的网络或系统中。在理想情况下,任何计算机和计算机集群都不会生成…

css3学习总结6--CSS3字体

使用自己需要的字体 在新的 font-face 规则中,您必须首先定义字体的名称(比如 myFirstFont),然后指向该字体文件。 如需为 HTML 元素使用字体,请通过 font-family 属性来引用字体的名称 (myFirstFont): 实例…

气液增压泵特点详细介绍

森拓气液增压泵是一款以液压油、水及大部分化学腐蚀性液体为介质的增压产品,利用大面积活塞的低气压产生小面积活塞的高液压。气液增压泵已广泛应用到各个行业,其特点众多,下面就为大家介绍下。 气液增压泵特点: 输出范围广&#…

csdn排版问题

(一) 直接在word 文档中写好,然后复制到csdn 博客中 (二) 遇到代码 (三) 修改以前的文章,也建议先拷贝到word 中,先修改完格式再复制进去。 (四) 不要在粘贴代码行中另外加颜色等样式,该文章一下的格式…

java--Hibernate添加数据save

添加按钮跳转到add表单页面 <a href"${pageContext.request.contextPath }/department_saveUI.action">添加</a> 到struts.xml找到对应的Action <action name"department_*" class"departmentAction" method"{1}">&…

oracel 相关查询 Oracle Hint的用法

1. /*ALL_ROWS*/ 表明对语句块选择基于开销的优化方法,并获得最佳吞吐量,使资源消耗最小化. 例如: SELECT /*ALL_ROWS*/ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO’SCOTT’; 2. /*FIRST_ROWS*/ 表明对语句块选择基于开销的优化方法,并获得最佳响应时间,使资源消耗最小…

GNU make manual 翻译( 一百四十一)

继续翻译 5.6 Interrupting or Killing make If make gets a fatal signal while a shell is executing, it may delete the target file that the recipe was supposed to update. This is done if the target files last-modification time has changed since make first ch…

WIP 005 - Implement the search result page

Need to show the search result in a tablewalker You can show the tablewalker in the search page which is recommend, or you can show it in the search result screen. 转载于:https://www.cnblogs.com/wancy86/p/WIP005.html