美文网首页
iOS便捷打印模型

iOS便捷打印模型

作者: 幸福的鱼 | 来源:发表于2021-09-07 09:38 被阅读0次

    项目中接口返回值可能有几个或者几十个,每次都手动输入就会浪费很多时间,构造了一个便捷打印的方法,需要的同学可以拿去试下

    //输出 property

    + (void)logProperty:(NSDictionary*)dic{

        NSString*ss =@"";

        for(NSString *key in dic) {

            id value = dic[key];

            if([value isKindOfClass: [NSString class]]) {

                ss = [ss stringByAppendingFormat:@"@property (nonatomic, copy) NSString * %@;\n",key];

            }else if([value isKindOfClass: [NSNumber class]]){

                ss = [ss stringByAppendingFormat:@"@property (nonatomic, strong) NSNumber * %@;\n",key];

            }else if([valueisKindOfClass: [NSArrayclass]]){

                ss = [ss stringByAppendingFormat:@"@property (nonatomic, strong) NSArray * %@;\n",key];

            }else if([value isKindOfClass: [NSDictionary class]]){

                ss = [ss stringByAppendingFormat:@"@property (nonatomic, strong) NSDictionary * %@;\n",key];

            }else{

                ss = [ss stringByAppendingFormat:@"@property (nonatomic, strong) NSNumber * %@;\n",key];

            }

        }

        NSLog(@"\n%@",ss);

    }

    相关文章

      网友评论

          本文标题:iOS便捷打印模型

          本文链接:https://www.haomeiwen.com/subject/mopuwltx.html