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);
    }

  • 相关阅读:
    斯坦福【概率与统计】课程笔记(〇):前言
    斯坦福【概率与统计】课程笔记(二):从EDA开始
    dot
    左移右移
    树莓派系统烧写+网络配置
    windows上面捕获声卡数据
    python1
    继续进销存系统
    base64编码
    DES原理
  • 原文地址:https://www.cnblogs.com/soulDn/p/10567787.html
Copyright © 2011-2022 走看看