+ (NSMutableArray *)valuesForamtToStringWithArray:(NSArray *)array {
NSMutableArray * newArray = [NSMutableArray array];
for (id obj in array) {
id newObj;
if ([obj isKindOfClass:[NSNumber class]]) {
newObj = [NSString stringWithFormat:@"%@",obj];
}else if ([obj isKindOfClass:[NSDictionary class]]) {
newObj = [self valuesForamtToStringWithDict:obj];
}else if ([obj isKindOfClass:[NSArray class]]){
newObj = [self valuesForamtToStringWithArray:obj];
}else if ([obj isKindOfClass:[NSNull class]]){
newObj = @"";
}else {
newObj = obj;
}
[newArray addObject:newObj];
}
return newArray;
}
+ (NSMutableDictionary *)valuesForamtToStringWithDict:(NSDictionary *)dict {
__block NSMutableDictionary * newDict = [NSMutableDictionary dictionary];
[dict enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
NSString *newKey = [NSString stringWithFormat:@"%@",key];
id newObj;
if ([obj isKindOfClass:[NSNumber class]]) {
newObj = [NSString stringWithFormat:@"%@",obj];
}else if ([obj isKindOfClass:[NSDictionary class]]) {
newObj = [self valuesForamtToStringWithDict:obj];
}else if ([obj isKindOfClass:[NSArray class]]){
newObj = [self valuesForamtToStringWithArray:obj];
}else if ([obj isKindOfClass:[NSNull class]]){
newObj = @"";
}else {
newObj = obj;
}
newDict[newKey] = newObj;
}];
return newDict;
}
网友评论