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:@"\n%@\n",code];
}];
NSLog(@"codes = %@",codes);
}