zoukankan      html  css  js  c++  java
  • 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:@" %@ ",code];

    }];
    NSLog(@"codes = %@",codes);
    }

  • 相关阅读:
    Java学习之路(四)
    HTML学习之canves元素
    一些常用的SQL查询语句
    数据库实现动态表头
    Java学习之路(三)
    Java学习之路(二)
    Java学习之路(一)
    UML类图几种关系的总结(转)
    vue 项目全局修改element-ui的样式
    NGINX 资料
  • 原文地址:https://www.cnblogs.com/soulDn/p/10567787.html
Copyright © 2011-2022 走看看