JSON转NSDictionary后遍历多维的NSDictionary
1 - (NSString *)stringFormDict:(NSDictionary*)dict 2 { 3 NSMutableString *str = [NSMutableString string]; 4 NSArray *keys = [dict allKeys]; 5 for (NSString *key in keys) { 6 if ([[dict objectForKey:key] isKindOfClass:[NSDictionary class]]) { 7 id obj = [dict objectForKey:key]; 8 [str appendFormat:@"\n%@: %@",key,[self stringFormDict:obj]]; 9 }else if ([[dict objectForKey:key] isKindOfClass:[NSArray class]]){10 [str appendFormat:@"\n%@:",key];11 for (id obj in [dict objectForKey:key]) {12 [str appendFormat:@"\n%@",[self stringFormDict:obj]];13 }14 }else{15 [str appendFormat:@"\n%@: %@",key,[dict objectForKey:key]];16 }17 }18 return str;19 }
TAG: