-(NSString *)PropertyNameCreatewithDict:(NSDictionary*)dict
{
NSMutableString *mutStr = [NSMutableString string];
[dict enumerateKeysAndObjectsUsingBlock:^(id _Nonnull propertyName, id _Nonnull value, BOOL * _Nonnull stop) {
NSLog(@"%@", [value class]);
if ([value isKindOfClass:[NSNull class]])
{
return;
}
NSString *resultStr = @"";
if ([value isKindOfClass:NSClassFromString(@"NSTaggedPointerString")]) {
resultStr = [NSString stringWithFormat:@"@property (nonatomic, strong) NSString *%@;",propertyName];
}else if ([NSStringFromClass([value class])containsString:@"Dictionary"]){
resultStr = [NSString stringWithFormat:@"@property (nonatomic, strong) NSDictionary *%@;",propertyName];
}
else if ([value isEqual:@""])
{
resultStr = [NSString stringWithFormat:@"@property (nonatomic, assign)NSString *%@;",propertyName];
}
else if ([value isKindOfClass:NSClassFromString(@"__NSCFBoolean")])
{
resultStr = [NSString stringWithFormat:@"@property (nonatomic, assign) BOOL %@;",propertyName];
}
else if ([NSStringFromClass([value class])containsString:@"Array"]){
resultStr = [NSString stringWithFormat:@"@property (nonatomic, strong) NSArray *%@;",propertyName];
}
else if ([value isKindOfClass:NSClassFromString(@"__NSArrayI")])
{
resultStr = [NSString stringWithFormat:@"@property (nonatomic, strong) NSArray *%@;",propertyName];
}
else if ([value isKindOfClass:NSClassFromString(@"__NSDictionaryI ")])
{
resultStr = [NSString stringWithFormat:@"@property (nonatomic, strong) NSDictionary *%@;",propertyName];
}
else if ([value isKindOfClass:NSClassFromString(@"__NSCFNumber")])
{
resultStr = [NSString stringWithFormat:@"@property (nonatomic, assign) int %@;",propertyName];
}
else if ([value isKindOfClass:NSClassFromString(@"__NSCFDate")])
{
resultStr = [NSString stringWithFormat:@"@property (nonatomic, assign) NSDate *%@;",propertyName];
}
if (resultStr.length > 0) {
[mutStr appendFormat:@"\n%@\n",resultStr];
}
}];
return mutStr;
}
网友评论