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