-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSDictionary+ConverttoString.m
44 lines (32 loc) · 1.28 KB
/
NSDictionary+ConverttoString.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#import "NSDictionary+ConverttoString.h"
@implementation NSDictionary (ConverttoString)
+(NSDictionary *) getStringBasedDictionary:(NSDictionary *) dict
{
NSMutableDictionary *dictOutput=[NSMutableDictionary dictionary];
for (NSObject *obj in dict) {
if([[dict objectForKey:obj] isKindOfClass:[NSArray class]])
{
[dictOutput setObject:[self getArray:[dict objectForKey:obj]] forKey:[NSString stringWithFormat:@"%@",obj]];
}
else if([[dict objectForKey:obj] isKindOfClass:[NSDictionary class]])
{
[dictOutput setObject:[NSDictionary getStringBasedDictionary:[dict objectForKey:obj]] forKey:[NSString stringWithFormat:@"%@",obj]];
}
else
{
[dictOutput setObject:[NSString stringWithFormat:@"%@",[dict objectForKey:obj]] forKey:[NSString stringWithFormat:@"%@",obj]];
}
}
return dictOutput;
}
+(NSMutableArray *) getArray:(NSArray *)arrTemp
{
NSMutableArray *arrLocal=[NSMutableArray array];
for (NSObject *obj in arrTemp) {
if ([obj isKindOfClass:[NSDictionary class]]) {
[arrLocal addObject:[NSDictionary getStringBasedDictionary:[NSDictionary dictionaryWithDictionary:obj]]];
}
}
return arrLocal;
}
@end